aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Love <[email protected]>2003-08-20 16:47:48 +0000
committerDave Love <[email protected]>2003-08-20 16:47:48 +0000
commit41634167eb9256bde86d3f034ed082ec4cb6dc97 (patch)
tree2ad56ef9c7ff13f9ad8a7fe217691e9ff3a2845c /src
parentd748931263143cb7d97b0b1c421ba9f9fd1439eb (diff)
Some merging with gnulib. Change logic and doc
concerning (x)malloc/(x)free -- no longer Emacs-specific. [DO_BLOCK_INPUT]: Don't include lisp.h. (xmalloc, xfree): Declare. (malloc): Don't declare.
Diffstat (limited to 'src')
-rw-r--r--src/alloca.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/alloca.c b/src/alloca.c
index 4b574374bf..b7dff00264 100644
--- a/src/alloca.c
+++ b/src/alloca.c
@@ -36,7 +36,6 @@
#endif
#ifdef DO_BLOCK_INPUT
-# include "lisp.h"
# include "blockinput.h"
#endif
@@ -58,7 +57,10 @@ you
lose
-- must know STACK_DIRECTION at compile-time
/* Using #error here is not wise since this file should work for
- old and obscure compilers. */
+ old and obscure compilers.
+
+ As far as I know, using it is OK if it's indented -- at least for
+ pcc-based processors. -- fx */
# endif /* STACK_DIRECTION undefined */
# endif /* static */
# endif /* emacs */
@@ -73,38 +75,32 @@ long i00afunc ();
# define ADDRESS_FUNCTION(arg) &(arg)
# endif
-# ifdef POINTER_TYPE
+# ifndef POINTER_TYPE
+# ifdef __STDC__
+# define POINTER_TYPE void
+# else
+# define POINTER_TYPE char
+# endif
+# endif
typedef POINTER_TYPE *pointer;
-# else /* not POINTER_TYPE */
-# if __STDC__
-typedef void *pointer;
-# else /* not __STDC__ */
-typedef char *pointer;
-# endif /* not __STDC__ */
-# endif /* not POINTER_TYPE */
# ifndef NULL
# define NULL 0
# endif
-/* Different portions of Emacs need to call different versions of
- malloc. The Emacs executable needs alloca to call xmalloc, because
- ordinary malloc isn't protected from input signals. On the other
- hand, the utilities in lib-src need alloca to call malloc; some of
- them are very simple, and don't have an xmalloc routine.
-
- Non-Emacs programs expect this to call xmalloc.
+/* The Emacs executable needs alloca to call xmalloc, because ordinary
+ malloc isn't protected from input signals. xmalloc also checks for
+ out-of-memory errors, so we should use it generally.
Callers below should use malloc. */
-# ifdef emacs
-# undef malloc
-# define malloc xmalloc
-# ifdef EMACS_FREE
-# define free EMACS_FREE
-# endif
-# endif
-extern pointer malloc ();
+# undef malloc
+# define malloc xmalloc
+# undef free
+# define free xfree
+
+void *xmalloc _P ((size_t));
+void xfree _P ((void *))
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
@@ -229,8 +225,8 @@ alloca (size)
/* Allocate combined header + user data storage. */
{
- register pointer new = malloc (sizeof (header) + size);
/* Address of header. */
+ register pointer new = malloc (sizeof (header) + size);
if (new == 0)
abort();