about summary refs log tree commit diff
path: root/malloc/dynarray_resize_clear.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-01-11 12:03:38 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-02-09 16:57:54 -0300
commitde0e1b45b0aba18ce50de40e42028af2c50e335c (patch)
treef664f8441cd9d2a9eb696265951ca3d01e7a5bd3 /malloc/dynarray_resize_clear.c
parentc8ba52ab3350c334d6e34b1439a4c0c1431351f3 (diff)
downloadglibc-de0e1b45b0aba18ce50de40e42028af2c50e335c.tar.gz
glibc-de0e1b45b0aba18ce50de40e42028af2c50e335c.tar.xz
glibc-de0e1b45b0aba18ce50de40e42028af2c50e335c.zip
malloc: Sync dynarray with gnulib
It syncs with gnulib version a8bac4d49.  The main changes are:

  - Remove the usage of anonymous union within DYNARRAY_STRUCT.
  - Use DYNARRAY_FREE instead of DYNARRAY_NAME (free) so that
    Gnulib does not change 'free' to 'rpl_free'.
  - Use __nonnull instead of __attribute__ ((nonnull ())).
  - Use __attribute_maybe_unused__ instead of
    __attribute__ ((unused, nonnull (1))).
  - Use of _Noreturn instead of _attribute__ ((noreturn)).

The only difference with gnulib is:

--- glibc
+++ gnulib
@@ -18,6 +18,7 @@

 #include <dynarray.h>
 #include <stdio.h>
+#include <stdlib.h>

 void
 __libc_dynarray_at_failure (size_t size, size_t index)
@@ -27,7 +28,6 @@
   __snprintf (buf, sizeof (buf), "Fatal glibc error: "
               "array index %zu not less than array length %zu\n",
               index, size);
- __libc_fatal (buf);
 #else
  abort ();
 #endif

It seems a wrong sync from gnulib (the code is used on loader and
thus it requires __libc_fatal instead of abort).

Checked on x86_64-linux-gnu.
Diffstat (limited to 'malloc/dynarray_resize_clear.c')
-rw-r--r--malloc/dynarray_resize_clear.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/malloc/dynarray_resize_clear.c b/malloc/dynarray_resize_clear.c
index 51d64fea5c..e893d1d58e 100644
--- a/malloc/dynarray_resize_clear.c
+++ b/malloc/dynarray_resize_clear.c
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <dynarray.h>
-#include <stdlib.h>
 #include <string.h>
 
 bool
@@ -28,7 +27,8 @@ __libc_dynarray_resize_clear (struct dynarray_header *list, size_t size,
   if (!__libc_dynarray_resize (list, size, scratch, element_size))
     return false;
   /* __libc_dynarray_resize already checked for overflow.  */
-  memset (list->array + (old_size * element_size), 0,
+  char *array = list->array;
+  memset (array + (old_size * element_size), 0,
           (size - old_size) * element_size);
   return true;
 }