bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH] scratch_buffer: sync from glibc
Date: Sat,  7 Sep 2019 22:15:13 -0700	[thread overview]
Message-ID: <20190908051513.27719-1-eggert@cs.ucla.edu> (raw)

* config/srclist.txt: Add the scratch_buffer source
code from glibc, since these should be in sync.
Autoupdate.
---
 ChangeLog                                 | 7 +++++++
 config/srclist.txt                        | 4 ++++
 lib/malloc/scratch_buffer.h               | 6 +++---
 lib/malloc/scratch_buffer_grow_preserve.c | 4 ++--
 lib/timegm.c                              | 2 +-
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4e009db52..28a6b264b 100644
--- 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.
diff --git a/config/srclist.txt b/config/srclist.txt
index 6d37729ce..4a3a5a7af 100644
--- a/config/srclist.txt
+++ b/config/srclist.txt
@@ -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
diff --git a/lib/malloc/scratch_buffer.h b/lib/malloc/scratch_buffer.h
index f83e1004b..0482773ac 100644
--- a/lib/malloc/scratch_buffer.h
+++ b/lib/malloc/scratch_buffer.h
@@ -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);
 }
 
diff --git a/lib/malloc/scratch_buffer_grow_preserve.c b/lib/malloc/scratch_buffer_grow_preserve.c
index c3c6de18f..62fcc656b 100644
--- a/lib/malloc/scratch_buffer_grow_preserve.c
+++ b/lib/malloc/scratch_buffer_grow_preserve.c
@@ -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
     {
diff --git a/lib/timegm.c b/lib/timegm.c
index bae0ceee5..00854c796 100644
--- a/lib/timegm.c
+++ b/lib/timegm.c
@@ -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>
-- 
2.21.0



                 reply	other threads:[~2019-09-08  5:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190908051513.27719-1-eggert@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).