From 948f64a183b75de140fd86fefd72b35fda082887 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 21 Jan 2000 15:27:39 +0000 Subject: [PATCH] Added G_N_ELEMENTS macro to determine the number of elements in an array. Fri Jan 21 10:18:24 2000 Owen Taylor * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine the number of elements in an array. --- ChangeLog | 5 +++++ ChangeLog.pre-2-0 | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-2 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ glib.h | 5 +++++ glib/glib.h | 5 +++++ 10 files changed, 50 insertions(+) diff --git a/ChangeLog b/ChangeLog index ef72dca83..8731bf1ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ef72dca83..8731bf1ad 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Fri Jan 21 10:18:24 2000 Owen Taylor + + * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine + the number of elements in an array. + Sun Jan 9 13:28:36 2000 Tim Janik * gstrfuncs.c (g_strtod): correctly fetch the current locale, diff --git a/glib.h b/glib.h index b94c94540..92397dddb 100644 --- a/glib.h +++ b/glib.h @@ -134,6 +134,11 @@ extern "C" { #define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) #define G_STRINGIFY_ARG(contents) #contents +/* Count the number of elements in an array. The array must be defined + * as such; using this with a dynamically allocated array will give + * incorrect results. + */ +#define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0])) /* Define G_VA_COPY() to do the right thing for copying va_list variables. * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy. diff --git a/glib/glib.h b/glib/glib.h index b94c94540..92397dddb 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -134,6 +134,11 @@ extern "C" { #define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) #define G_STRINGIFY_ARG(contents) #contents +/* Count the number of elements in an array. The array must be defined + * as such; using this with a dynamically allocated array will give + * incorrect results. + */ +#define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0])) /* Define G_VA_COPY() to do the right thing for copying va_list variables. * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.