bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] Re: drop unlocked-io dependency in getline module?


From: Paul Eggert
Subject: Re: [Bug-gnulib] Re: drop unlocked-io dependency in getline module?
Date: 24 Nov 2003 13:42:30 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

> > > alloca.c: depends on xmalloc, which I don't always want to use
> > > (especially if just copy the file and use AC_FUNC_ALLOCA).
> > 
> > Come to think of it, perhaps that dependency should be removed....
> 
> Agreed....

OK, I installed this.

Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/ChangeLog,v
retrieving revision 1.119
diff -p -u -r1.119 ChangeLog
--- ChangeLog   17 Nov 2003 21:58:05 -0000      1.119
+++ ChangeLog   24 Nov 2003 21:37:27 -0000
@@ -1,3 +1,7 @@
+2003-11-24  Paul Eggert  <address@hidden>
+
+       * modules/alloca: Remove dependency on xalloc.
+
 2003-11-17  Paul Eggert  <address@hidden>
 
        * README: Mention that S+T cannot overflow if S is the size of
Index: modules/alloca
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/alloca,v
retrieving revision 1.8
diff -p -u -r1.8 alloca
--- modules/alloca      17 Aug 2003 03:17:36 -0000      1.8
+++ modules/alloca      24 Nov 2003 21:37:27 -0000
@@ -7,7 +7,6 @@ lib/alloca.c
 m4/alloca.m4
 
 Depends-on:
-xalloc
 
 configure.ac:
 gl_FUNC_ALLOCA
Index: lib/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.619
diff -p -u -r1.619 ChangeLog
--- lib/ChangeLog       22 Nov 2003 15:08:27 -0000      1.619
+++ lib/ChangeLog       24 Nov 2003 21:37:33 -0000
@@ -1,3 +1,13 @@
+2003-11-24  Paul Eggert  <address@hidden>
+
+       * lib/alloca.c: Remove dependency on xalloc module.
+       (xalloc_die): Remove.
+       (memory_full) [!defined emacs]: New macro.
+       [!defined emacs]: Don't include xalloc.h.
+       (alloca): Invoke memory_full, not xalloc_die, if malloc fails or
+       address arithmetic overflows.  Change datatypes a bit to avoid
+       unnecessary casts.
+
 2003-11-22  Jim Meyering  <address@hidden>
 
        * xmalloc.c (x2nrealloc_inline): Fix typos in comments: s/size/size_t/.
Index: lib/alloca.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/alloca.c,v
retrieving revision 1.12
diff -p -u -r1.12 alloca.c
--- lib/alloca.c        27 Oct 2003 07:12:11 -0000      1.12
+++ lib/alloca.c        24 Nov 2003 21:37:34 -0000
@@ -31,13 +31,12 @@
 #ifdef emacs
 # include "lisp.h"
 # include "blockinput.h"
-# define xalloc_die() memory_full ()
 # ifdef EMACS_FREE
 #  undef free
 #  define free EMACS_FREE
 # endif
 #else
-# include <xalloc.h>
+# define memory_full() abort ()
 #endif
 
 /* If compiling with GCC 2, this file's not needed.  */
@@ -196,22 +195,25 @@ alloca (size_t size)
 
   {
     /* Address of header.  */
-    register void *new;
+    register header *new;
 
     size_t combined_size = sizeof (header) + size;
     if (combined_size < sizeof (header))
-      xalloc_die ();
+      memory_full ();
 
-    new = xmalloc (combined_size);
+    new = malloc (combined_size);
 
-    ((header *) new)->h.next = last_alloca_header;
-    ((header *) new)->h.deep = depth;
+    if (! new)
+      memory_full ();
 
-    last_alloca_header = (header *) new;
+    new->h.next = last_alloca_header;
+    new->h.deep = depth;
+
+    last_alloca_header = new;
 
     /* User storage begins just after header.  */
 
-    return (void *) ((char *) new + sizeof (header));
+    return (void *) (new + 1);
   }
 }
 




reply via email to

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