]> Savannah Git Hosting - gnulib.git/commitdiff
scratch_buffer: sync from glibc
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 8 Sep 2019 05:13:08 +0000 (22:13 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 8 Sep 2019 05:15:01 +0000 (22:15 -0700)
* config/srclist.txt: Add the scratch_buffer source
code from glibc, since these should be in sync.
Autoupdate.

ChangeLog
config/srclist.txt
lib/malloc/scratch_buffer.h
lib/malloc/scratch_buffer_grow_preserve.c
lib/timegm.c

index 4e009db522b74f5f27f4a4bd636332b87da65e90..28a6b264b3baf26dda20f14b2a94d340e4766235 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-09-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       scratch_buffer: sync from glibc
+       * config/srclist.txt: Add the scratch_buffer source
+       code from glibc, since these should be in sync.
+       Autoupdate.
+
 2019-09-07  Bruno Haible  <bruno@clisp.org>
 
        doc: Update for glibc 2.30.
index 6d37729cefe571a410269d10a0e8cc7ab698fe33..4a3a5a7af066f6d56dfd0de0b2380b459ba97d42 100644 (file)
@@ -46,6 +46,10 @@ $GNUORG Copyright/request-assign.future              doc/Copyright
 $GNUORG Copyright/request-assign.program       doc/Copyright
 $GNUORG Copyright/request-disclaim.changes     doc/Copyright
 
+$LIBCSRC include/scratch_buffer.h      lib/malloc
+$LIBCSRC malloc/scratch_buffer_grow.c  lib/malloc
+$LIBCSRC malloc/scratch_buffer_grow_preserve.c lib/malloc
+$LIBCSRC malloc/scratch_buffer_set_array_size.c        lib/malloc
 # Temporarily newer in Gnulib than in glibc.
 #$LIBCSRC include/intprops.h             lib
 $LIBCSRC posix/regcomp.c               lib
index f83e1004b230c7d4ebbd0b1f8db94ce0f7fee6d5..0482773acce2fe0b5211688518b0ab0fa9907e9c 100644 (file)
@@ -66,7 +66,7 @@
 struct scratch_buffer {
   void *data;    /* Pointer to the beginning of the scratch area.  */
   size_t length; /* Allocated space at the data pointer, in bytes.  */
-  max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)];
+  union { max_align_t __align; char __c[1024]; } __space;
 };
 
 /* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space
@@ -74,7 +74,7 @@ struct scratch_buffer {
 static inline void
 scratch_buffer_init (struct scratch_buffer *buffer)
 {
-  buffer->data = buffer->__space;
+  buffer->data = buffer->__space.__c;
   buffer->length = sizeof (buffer->__space);
 }
 
@@ -82,7 +82,7 @@ scratch_buffer_init (struct scratch_buffer *buffer)
 static inline void
 scratch_buffer_free (struct scratch_buffer *buffer)
 {
-  if (buffer->data != buffer->__space)
+  if (buffer->data != buffer->__space.__c)
     free (buffer->data);
 }
 
index c3c6de18fc68248364370e8c61ed0add447a7207..62fcc656b62f6d21ba8ac38864724aa6e0a807ab 100644 (file)
@@ -30,14 +30,14 @@ __libc_scratch_buffer_grow_preserve (struct scratch_buffer *buffer)
   size_t new_length = 2 * buffer->length;
   void *new_ptr;
 
-  if (buffer->data == buffer->__space)
+  if (buffer->data == buffer->__space.__c)
     {
       /* Move buffer to the heap.  No overflow is possible because
         buffer->length describes a small buffer on the stack.  */
       new_ptr = malloc (new_length);
       if (new_ptr == NULL)
        return false;
-      memcpy (new_ptr, buffer->__space, buffer->length);
+      memcpy (new_ptr, buffer->__space.__c, buffer->length);
     }
   else
     {
index bae0ceee5e2b1b56b491696ede42586df2a29e57..00854c796ae1ce26cbc9fe2718c2881bd3f78c90 100644 (file)
@@ -15,7 +15,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #ifndef _LIBC
 # include <libc-config.h>