bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] proposed xalloc-related changes to array-list, array-os


From: Bruno Haible
Subject: Re: [bug-gnulib] proposed xalloc-related changes to array-list, array-oset, etc.
Date: Tue, 7 Nov 2006 15:28:13 +0100
User-agent: KMail/1.9.1

Paul Eggert wrote:
> 2006-11-06  Paul Eggert  <address@hidden>
> 
>       Simplify xmalloc expressions. Add overflow check in xmalloc arguments.
>       * lib/gl_anyavltree_list2.h (create_subtree_with_contents):
>       (gl_tree_create, gl_tree_add_first, gl_tree_add_last):
>       (gl_tree_add_before, gl_tree_add_after):
>       Use XMALLOC instead of xmalloc, and XCALLOC instead of xzalloc.
>       * lib/gl_anyhash_list2.h (hash_resize): Likewise.
>       * lib/gl_anylinked_list2.h (gl_linked_create_empty, gl_linked_create):
>       (gl_linked_add_first, gl_linked_add_last, gl_linked_add_before):
>       (gl_linked_add_after, gl_linked_add_at): Likewise.
>       * lib/gl_anyrbtree_list2.h (create_subtree_with_contents):
>       (gl_tree_create, gl_tree_add_first, gl_tree_add_last):
>       (gl_tree_add_before, gl_tree_add_after): Likewise.
>       * lib/gl_anytree_list2.h (gl_tree_create_empty): Likewise.
>       * lib/gl_anytree_oset.h (gl_tree_create_empty): Likewise.
>       * lib/gl_anytreehash_list1.h (add_to_bucket): Likewise.

Thanks, I applied this. I had missed the occurrences in the *.h files.

>       * lib/gl_array_list.c (gl_array_create): Use xmemdup instead
>       of XNMALLOC followed by memcpy.
>       * lib/gl_carray_list.c (gl_carray_create): Likewise.

Hmm, I find the code a little bit more understandable if the allocation
of the array is a different step than filling it (because the way it's
filled depends on the way the initial contents is presented). It's a close
tie, though.

>       * lib/gl_array_list.c (grow): Use x2nrealloc rather than
>       doing the work ourselves.
>       * lib/gl_array_oset.c (grow): Likewise.

I'll consider this. One one hand, x2nrealloc is a bit hard to understand.
OTOH, the current code has too many occurrences of the element type...

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]