Paul Eggert wrote: > > #ifdef __cplusplus > > #define XALLOC_WITH_EXPRESSION(N,EXPR) xalloc_with_expression (N, &(EXPR)) > > That doesn't look right in general, since there can be side effects in > computing the address of EXPR.
And also, if the programmer writes result = XALLOC_WITH_EXPRESSION (N, result); instead of result = XALLOC_WITH_EXPRESSION (N, *result); the macro will allocate only 4 bytes for each element. Big pitfall. > But since you prefer the XALLOC_WITH_TYPE > variants anyway, perhaps it's not worth looking into this. OK, I'm dropping the XALLOC_WITH_EXPRESSION variant. > How about this further elaboration of the XNMALLOC idea? It's a bit > more efficient in the case where n is 1. > > #if !HAVE__BUILTIN_CONSTANT_P > # define __builtin_constant_p(n) 0 > #endif > > #define __XALLOC_IS_1(x) (__builtin_constant_p(n) && ((n) == 1)) > > /* Return an array of N newly allocated objects each of type T. */ > #define XNMALLOC(n, t) \ > ((t *) (__XALLOC_IS_1 (n) ? xmalloc (sizeof (t)) : xnmalloc (n, sizeof (t))) I think the case to optimize for is the one that sizeof (t) is a constant expression; this is much more frequent than n == 1. (Among dozens of changes to use the new macros, I encountered only one case of n == 1.) > Another possibility would be to have XMALLOC and XZALLOC macros, where > it's assumed N is 1; this would be more efficient on non-GCC > platforms. Maybe that's better, since it's a bit clearer anyway. Yes, I like the idea. It makes it easy to remember the names of the macros: just like the function, but uppercased. I applied the following patch. 2006-11-03 Bruno Haible <[EMAIL PROTECTED]> Simplify xmalloc expressions. Add overflow check in xmalloc arguments. * m4/xalloc.m4 (gl_PREREQ_XALLOC): Require AC_C_INLINE. * lib/xalloc.h (XMALLOC, XNMALLOC, XZALLOC, XCALLOC): New macros. (xnboundedmalloc): New inline function. * lib/classpath.c (new_classpath): Use XNMALLOC instead of xmalloc. * lib/clean-temp.c (create_temp_dir): Use XNMALLOC, XMALLOC instead of xmalloc. * lib/concatpath.c (concatenated_pathname): Use XNMALLOC instead of xmalloc. * lib/fatal-signal.c (at_fatal_signal): Use XNMALLOC instead of xmalloc. * lib/findprog.c (find_in_path): Use XNMALLOC instead of xmalloc. * lib/gl_array_list.c (gl_array_create_empty): Use XMALLOC instead of xmalloc. (gl_array_create): Use XNMALLOC, XMALLOC instead of xmalloc. * lib/gl_array_oset.c (gl_array_create_empty): Use XNMALLOC instead of xmalloc. * lib/gl_avltree_oset.c (gl_tree_add_first, gl_tree_add_before, gl_tree_add_after): Use XMALLOC instead of xmalloc. * lib/gl_carray_list.c (gl_carray_create_empty): Use XMALLOC instead of xmalloc. (gl_carray_create): Use XNMALLOC, XMALLOC instead of xmalloc. * lib/gl_rbtree_oset.c (gl_tree_add_first, gl_tree_add_before, gl_tree_add_after): Use XMALLOC instead of xmalloc. * lib/gl_sublist.c (gl_sublist_create): Use XMALLOC instead of xmalloc. * lib/pagealign_alloc.c (new_memnode): Use XMALLOC instead of xmalloc. * lib/sh-quote.c (shell_quote_argv): Use XNMALLOC instead of xmalloc. * lib/xvasprintf.c (xstrcat): Use XNMALLOC instead of xmalloc. diff -r -c3 --exclude=CVS gnulib-20061026/lib/xalloc.h gnulib-20061026-modified/lib/xalloc.h *** gnulib-20061026/lib/xalloc.h 2006-11-04 02:09:43.000000000 +0100 --- gnulib-20061026-modified/lib/xalloc.h 2006-11-04 02:04:42.000000000 +0100 *************** *** 71,82 **** # define xalloc_oversized(n, s) \ ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) ! /* Return a pointer to a new buffer of S bytes. This is like xmalloc, ! except it returns char *. */ static inline char * ! xcharalloc (size_t s) { ! return (char *) xmalloc (s); } # ifdef __cplusplus --- 71,127 ---- # define xalloc_oversized(n, s) \ ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) ! /* In the following macros, T must be an elementary or structure/union or ! typedef'ed type, or a pointer to such a type. To apply one of the ! following macros to a function pointer or array type, you need to typedef ! it first and use the typedef name. */ ! ! /* Allocate an object of type T dynamically, with error checking. */ ! /* extern T *XMALLOC (typename T); */ ! #define XMALLOC(T) \ ! ((T *) xmalloc (sizeof (T))) ! ! /* Allocate memory for NMEMB elements of type T, with error checking. */ ! /* extern T *XNMALLOC (size_t nmemb, typename T); */ ! #if HAVE_INLINE ! /* xnmalloc performs a division and multiplication by sizeof (T). Arrange to ! perform the division at compile-time and the multiplication with a factor ! known at compile-time. */ ! # define XNMALLOC(N,T) \ ! ((T *) (sizeof (T) == 1 \ ! ? xmalloc (N) \ ! : xnboundedmalloc(N, (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / sizeof (T), sizeof (T)))) ! static inline void * ! xnboundedmalloc (size_t n, size_t bound, size_t s) ! { ! if (n > bound) ! xalloc_die (); ! return xmalloc (n * s); ! } ! #else ! # define XNMALLOC(N,T) \ ! ((T *) (sizeof (T) == 1 ? xmalloc (N) : xnmalloc (N, sizeof (T)))) ! #endif ! ! /* Allocate an object of type T dynamically, with error checking, ! and zero it. */ ! /* extern T *XZALLOC (typename T); */ ! #define XZALLOC(T) \ ! ((T *) xzalloc (sizeof (T))) ! ! /* Allocate memory for NMEMB elements of type T, with error checking, ! and zero it. */ ! /* extern T *XCALLOC (size_t nmemb, typename T); */ ! #define XCALLOC(N,T) \ ! ((T *) xcalloc (N, sizeof (T))) ! ! /* Return a pointer to a new buffer of N bytes. This is like xmalloc, ! except it returns char *. ! xcharalloc (N) is equivalent to XNMALLOC (N, char). */ static inline char * ! xcharalloc (size_t n) { ! return (char *) xmalloc (n); } # ifdef __cplusplus diff -r -c3 gnulib-20061026/lib/classpath.c gnulib-20061026-modified/lib/classpath.c *** gnulib-20061026/lib/classpath.c 2006-09-19 00:51:16.000000000 +0200 --- gnulib-20061026-modified/lib/classpath.c 2006-11-04 01:21:58.000000000 +0100 *************** *** 66,72 **** if (classpaths_count > 0 && old_classpath[0] == '\0') length--; ! result = (char *) xmalloc (length + 1); p = result; for (i = 0; i < classpaths_count; i++) { --- 66,72 ---- if (classpaths_count > 0 && old_classpath[0] == '\0') length--; ! result = XNMALLOC (length + 1, char); p = result; for (i = 0; i < classpaths_count; i++) { diff -r -c3 --exclude=CVS gnulib-20061026/lib/clean-temp.c gnulib-20061026-modified/lib/clean-temp.c *** gnulib-20061026/lib/clean-temp.c 2006-11-04 02:09:38.000000000 +0100 --- gnulib-20061026-modified/lib/clean-temp.c 2006-11-04 01:22:45.000000000 +0100 *************** *** 273,280 **** size_t old_allocated = cleanup_list.tempdir_allocated; size_t new_allocated = 2 * cleanup_list.tempdir_allocated + 1; struct tempdir * volatile *new_array = ! (struct tempdir * volatile *) ! xmalloc (new_allocated * sizeof (struct tempdir * volatile)); if (old_allocated == 0) /* First use of this facility. Register the cleanup handler. */ --- 273,279 ---- size_t old_allocated = cleanup_list.tempdir_allocated; size_t new_allocated = 2 * cleanup_list.tempdir_allocated + 1; struct tempdir * volatile *new_array = ! XNMALLOC (new_allocated, struct tempdir * volatile); if (old_allocated == 0) /* First use of this facility. Register the cleanup handler. */ *************** *** 306,312 **** } /* Initialize a 'struct tempdir'. */ ! tmpdir = (struct tempdir *) xmalloc (sizeof (struct tempdir)); tmpdir->dirname = NULL; tmpdir->cleanup_verbose = cleanup_verbose; tmpdir->subdirs = gl_list_create_empty (GL_LINKEDHASH_LIST, --- 305,311 ---- } /* Initialize a 'struct tempdir'. */ ! tmpdir = XMALLOC (struct tempdir); tmpdir->dirname = NULL; tmpdir->cleanup_verbose = cleanup_verbose; tmpdir->subdirs = gl_list_create_empty (GL_LINKEDHASH_LIST, diff -r -c3 --exclude=CVS gnulib-20061026/lib/concatpath.c gnulib-20061026-modified/lib/concatpath.c *** gnulib-20061026/lib/concatpath.c 2006-09-19 00:51:16.000000000 +0200 --- gnulib-20061026-modified/lib/concatpath.c 2006-11-04 01:23:26.000000000 +0100 *************** *** 42,50 **** if (strcmp (directory, ".") == 0) { /* No need to prepend the directory. */ ! result = (char *) xmalloc (strlen (filename) ! + (suffix != NULL ? strlen (suffix) : 0) ! + 1); p = result; } else --- 42,51 ---- if (strcmp (directory, ".") == 0) { /* No need to prepend the directory. */ ! result = XNMALLOC (strlen (filename) ! + (suffix != NULL ? strlen (suffix) : 0) ! + 1, ! char); p = result; } else *************** *** 53,62 **** int need_slash = (directory_len > FILE_SYSTEM_PREFIX_LEN (directory) && !ISSLASH (directory[directory_len - 1])); ! result = (char *) xmalloc (directory_len + need_slash ! + strlen (filename) ! + (suffix != NULL ? strlen (suffix) : 0) ! + 1); memcpy (result, directory, directory_len); p = result + directory_len; if (need_slash) --- 54,64 ---- int need_slash = (directory_len > FILE_SYSTEM_PREFIX_LEN (directory) && !ISSLASH (directory[directory_len - 1])); ! result = XNMALLOC (directory_len + need_slash ! + strlen (filename) ! + (suffix != NULL ? strlen (suffix) : 0) ! + 1, ! char); memcpy (result, directory, directory_len); p = result + directory_len; if (need_slash) diff -r -c3 --exclude=CVS gnulib-20061026/lib/fatal-signal.c gnulib-20061026-modified/lib/fatal-signal.c *** gnulib-20061026/lib/fatal-signal.c 2006-11-04 02:09:38.000000000 +0100 --- gnulib-20061026-modified/lib/fatal-signal.c 2006-11-04 01:23:54.000000000 +0100 *************** *** 206,213 **** size_t old_actions_allocated = actions_allocated; size_t new_actions_allocated = 2 * actions_allocated; actions_entry_t *new_actions = ! (actions_entry_t *) ! xmalloc (new_actions_allocated * sizeof (actions_entry_t)); size_t k; /* Don't use memcpy() here, because memcpy takes non-volatile arguments --- 206,212 ---- size_t old_actions_allocated = actions_allocated; size_t new_actions_allocated = 2 * actions_allocated; actions_entry_t *new_actions = ! XNMALLOC (new_actions_allocated, actions_entry_t); size_t k; /* Don't use memcpy() here, because memcpy takes non-volatile arguments diff -r -c3 --exclude=CVS gnulib-20061026/lib/findprog.c gnulib-20061026-modified/lib/findprog.c *** gnulib-20061026/lib/findprog.c 2006-11-04 02:09:38.000000000 +0100 --- gnulib-20061026-modified/lib/findprog.c 2006-11-04 01:24:19.000000000 +0100 *************** *** 92,98 **** /* Add the "./" prefix for real, that concatenated_pathname() optimized away. This avoids a second PATH search when the caller uses execlp/execvp. */ ! progpathname = (char *) xmalloc (2 + strlen (progname) + 1); progpathname[0] = '.'; progpathname[1] = '/'; memcpy (progpathname + 2, progname, strlen (progname) + 1); --- 92,98 ---- /* Add the "./" prefix for real, that concatenated_pathname() optimized away. This avoids a second PATH search when the caller uses execlp/execvp. */ ! progpathname = XNMALLOC (2 + strlen (progname) + 1, char); progpathname[0] = '.'; progpathname[1] = '/'; memcpy (progpathname + 2, progname, strlen (progname) + 1); diff -r -c3 --exclude=CVS gnulib-20061026/lib/gl_array_list.c gnulib-20061026-modified/lib/gl_array_list.c *** gnulib-20061026/lib/gl_array_list.c 2006-10-07 01:01:48.000000000 +0200 --- gnulib-20061026-modified/lib/gl_array_list.c 2006-11-04 01:25:21.000000000 +0100 *************** *** 58,65 **** gl_listelement_hashcode_fn hashcode_fn, bool allow_duplicates) { ! struct gl_list_impl *list = ! (struct gl_list_impl *) xmalloc (sizeof (struct gl_list_impl)); list->base.vtable = implementation; list->base.equals_fn = equals_fn; --- 58,64 ---- gl_listelement_hashcode_fn hashcode_fn, bool allow_duplicates) { ! struct gl_list_impl *list = XMALLOC (struct gl_list_impl); list->base.vtable = implementation; list->base.equals_fn = equals_fn; *************** *** 79,86 **** bool allow_duplicates, size_t count, const void **contents) { ! struct gl_list_impl *list = ! (struct gl_list_impl *) xmalloc (sizeof (struct gl_list_impl)); list->base.vtable = implementation; list->base.equals_fn = equals_fn; --- 78,84 ---- bool allow_duplicates, size_t count, const void **contents) { ! struct gl_list_impl *list = XMALLOC (struct gl_list_impl); list->base.vtable = implementation; list->base.equals_fn = equals_fn; *************** *** 88,95 **** list->base.allow_duplicates = allow_duplicates; if (count > 0) { ! list->elements = ! (const void **) xmalloc (count * sizeof (const void *)); memcpy (list->elements, contents, count * sizeof (const void *)); } else --- 86,92 ---- list->base.allow_duplicates = allow_duplicates; if (count > 0) { ! list->elements = XNMALLOC (count, const void *); memcpy (list->elements, contents, count * sizeof (const void *)); } else diff -r -c3 --exclude=CVS gnulib-20061026/lib/gl_array_oset.c gnulib-20061026-modified/lib/gl_array_oset.c *** gnulib-20061026/lib/gl_array_oset.c 2006-10-04 00:01:28.000000000 +0200 --- gnulib-20061026-modified/lib/gl_array_oset.c 2006-11-04 01:25:36.000000000 +0100 *************** *** 45,52 **** gl_array_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn) { ! struct gl_oset_impl *set = ! (struct gl_oset_impl *) xmalloc (sizeof (struct gl_oset_impl)); set->base.vtable = implementation; set->base.compar_fn = compar_fn; --- 45,51 ---- gl_array_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn) { ! struct gl_oset_impl *set = XMALLOC (struct gl_oset_impl); set->base.vtable = implementation; set->base.compar_fn = compar_fn; diff -r -c3 --exclude=CVS gnulib-20061026/lib/gl_avltree_oset.c gnulib-20061026-modified/lib/gl_avltree_oset.c *** gnulib-20061026/lib/gl_avltree_oset.c 2006-10-03 19:50:31.000000000 +0200 --- gnulib-20061026-modified/lib/gl_avltree_oset.c 2006-11-04 01:26:19.000000000 +0100 *************** *** 310,317 **** gl_tree_add_first (gl_oset_t set, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = ! (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl)); new_node->left = NULL; new_node->right = NULL; --- 310,316 ---- gl_tree_add_first (gl_oset_t set, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl); new_node->left = NULL; new_node->right = NULL; *************** *** 348,355 **** gl_tree_add_before (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = ! (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl)); bool height_inc; new_node->left = NULL; --- 347,353 ---- gl_tree_add_before (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl); bool height_inc; new_node->left = NULL; *************** *** 386,393 **** gl_tree_add_after (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = ! (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl)); bool height_inc; new_node->left = NULL; --- 384,390 ---- gl_tree_add_after (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl); bool height_inc; new_node->left = NULL; diff -r -c3 --exclude=CVS gnulib-20061026/lib/gl_carray_list.c gnulib-20061026-modified/lib/gl_carray_list.c *** gnulib-20061026/lib/gl_carray_list.c 2006-10-07 01:01:48.000000000 +0200 --- gnulib-20061026-modified/lib/gl_carray_list.c 2006-11-04 01:27:53.000000000 +0100 *************** *** 61,68 **** gl_listelement_hashcode_fn hashcode_fn, bool allow_duplicates) { ! struct gl_list_impl *list = ! (struct gl_list_impl *) xmalloc (sizeof (struct gl_list_impl)); list->base.vtable = implementation; list->base.equals_fn = equals_fn; --- 61,67 ---- gl_listelement_hashcode_fn hashcode_fn, bool allow_duplicates) { ! struct gl_list_impl *list = XMALLOC (struct gl_list_impl); list->base.vtable = implementation; list->base.equals_fn = equals_fn; *************** *** 83,90 **** bool allow_duplicates, size_t count, const void **contents) { ! struct gl_list_impl *list = ! (struct gl_list_impl *) xmalloc (sizeof (struct gl_list_impl)); list->base.vtable = implementation; list->base.equals_fn = equals_fn; --- 82,88 ---- bool allow_duplicates, size_t count, const void **contents) { ! struct gl_list_impl *list = XMALLOC (struct gl_list_impl); list->base.vtable = implementation; list->base.equals_fn = equals_fn; *************** *** 92,99 **** list->base.allow_duplicates = allow_duplicates; if (count > 0) { ! list->elements = ! (const void **) xmalloc (count * sizeof (const void *)); memcpy (list->elements, contents, count * sizeof (const void *)); } else --- 90,96 ---- list->base.allow_duplicates = allow_duplicates; if (count > 0) { ! list->elements = XNMALLOC (count, const void *); memcpy (list->elements, contents, count * sizeof (const void *)); } else diff -r -c3 --exclude=CVS gnulib-20061026/lib/gl_rbtree_oset.c gnulib-20061026-modified/lib/gl_rbtree_oset.c *** gnulib-20061026/lib/gl_rbtree_oset.c 2006-10-03 19:50:31.000000000 +0200 --- gnulib-20061026-modified/lib/gl_rbtree_oset.c 2006-11-04 01:28:28.000000000 +0100 *************** *** 542,549 **** gl_tree_add_first (gl_oset_t set, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = ! (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl)); new_node->left = NULL; new_node->right = NULL; --- 542,548 ---- gl_tree_add_first (gl_oset_t set, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl); new_node->left = NULL; new_node->right = NULL; *************** *** 578,585 **** gl_tree_add_before (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = ! (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl)); new_node->left = NULL; new_node->right = NULL; --- 577,583 ---- gl_tree_add_before (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl); new_node->left = NULL; new_node->right = NULL; *************** *** 607,614 **** gl_tree_add_after (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = ! (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl)); new_node->left = NULL; new_node->right = NULL; --- 605,611 ---- gl_tree_add_after (gl_oset_t set, gl_oset_node_t node, const void *elt) { /* Create new node. */ ! gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl); new_node->left = NULL; new_node->right = NULL; diff -r -c3 --exclude=CVS gnulib-20061026/lib/gl_sublist.c gnulib-20061026-modified/lib/gl_sublist.c *** gnulib-20061026/lib/gl_sublist.c 2006-10-07 21:30:45.000000000 +0200 --- gnulib-20061026-modified/lib/gl_sublist.c 2006-11-04 01:28:49.000000000 +0100 *************** *** 430,437 **** /* Invalid arguments. */ abort (); { ! struct gl_list_impl *list = ! (struct gl_list_impl *) xmalloc (sizeof (struct gl_list_impl)); list->base.vtable = &gl_sublist_list_implementation; list->base.equals_fn = whole_list->base.equals_fn; /* actually unused */ --- 430,436 ---- /* Invalid arguments. */ abort (); { ! struct gl_list_impl *list = XMALLOC (struct gl_list_impl); list->base.vtable = &gl_sublist_list_implementation; list->base.equals_fn = whole_list->base.equals_fn; /* actually unused */ diff -r -c3 --exclude=CVS gnulib-20061026/lib/pagealign_alloc.c gnulib-20061026-modified/lib/pagealign_alloc.c *** gnulib-20061026/lib/pagealign_alloc.c 2006-09-19 00:51:16.000000000 +0200 --- gnulib-20061026-modified/lib/pagealign_alloc.c 2006-11-04 01:29:40.000000000 +0100 *************** *** 81,87 **** static void new_memnode (void *aligned_ptr, info_t info) { ! memnode_t *new_node = (memnode_t *) xmalloc (sizeof (memnode_t)); new_node->aligned_ptr = aligned_ptr; new_node->info = info; new_node->next = memnode_table; --- 81,87 ---- static void new_memnode (void *aligned_ptr, info_t info) { ! memnode_t *new_node = XMALLOC (memnode_t); new_node->aligned_ptr = aligned_ptr; new_node->info = info; new_node->next = memnode_table; diff -r -c3 --exclude=CVS gnulib-20061026/lib/sh-quote.c gnulib-20061026-modified/lib/sh-quote.c *** gnulib-20061026/lib/sh-quote.c 2006-09-19 00:51:16.000000000 +0200 --- gnulib-20061026-modified/lib/sh-quote.c 2006-11-04 01:33:10.000000000 +0100 *************** *** 88,94 **** break; } ! command = (char *) xmalloc (length); p = command; for (argp = argv; ; ) --- 88,94 ---- break; } ! command = XNMALLOC (length, char); p = command; for (argp = argv; ; ) diff -r -c3 --exclude=CVS gnulib-20061026/lib/xvasprintf.c gnulib-20061026-modified/lib/xvasprintf.c *** gnulib-20061026/lib/xvasprintf.c 2006-10-20 00:23:38.000000000 +0200 --- gnulib-20061026-modified/lib/xvasprintf.c 2006-11-04 01:33:46.000000000 +0100 *************** *** 64,70 **** } /* Allocate and fill the result string. */ ! result = (char *) xmalloc (totalsize + 1); p = result; for (i = argcount; i > 0; i--) { --- 64,70 ---- } /* Allocate and fill the result string. */ ! result = XNMALLOC (totalsize + 1, char); p = result; for (i = argcount; i > 0; i--) { *** gnulib-20061026/m4/xalloc.m4 2006-08-22 14:50:24.000000000 +0200 --- gnulib-20061026-modified/m4/xalloc.m4 2006-11-04 02:22:08.000000000 +0100 *************** *** 1,4 **** ! # xalloc.m4 serial 13 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # xalloc.m4 serial 14 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 14,19 **** --- 14,20 ---- # Prerequisites of lib/xalloc.h. AC_DEFUN([gl_PREREQ_XALLOC], [ + AC_REQUIRE([AC_C_INLINE]) : ])