diff options
| author | Dave Love | 2003-08-20 16:47:48 +0000 |
|---|---|---|
| committer | Dave Love | 2003-08-20 16:47:48 +0000 |
| commit | 41634167eb9256bde86d3f034ed082ec4cb6dc97 (patch) | |
| tree | 2ad56ef9c7ff13f9ad8a7fe217691e9ff3a2845c /src | |
| parent | d748931263143cb7d97b0b1c421ba9f9fd1439eb (diff) | |
| download | emacs-41634167eb9256bde86d3f034ed082ec4cb6dc97.tar.gz emacs-41634167eb9256bde86d3f034ed082ec4cb6dc97.zip | |
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.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/alloca.c b/src/alloca.c index 4b574374bff..b7dff002648 100644 --- a/src/alloca.c +++ b/src/alloca.c | |||
| @@ -36,7 +36,6 @@ | |||
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | #ifdef DO_BLOCK_INPUT | 38 | #ifdef DO_BLOCK_INPUT |
| 39 | # include "lisp.h" | ||
| 40 | # include "blockinput.h" | 39 | # include "blockinput.h" |
| 41 | #endif | 40 | #endif |
| 42 | 41 | ||
| @@ -58,7 +57,10 @@ you | |||
| 58 | lose | 57 | lose |
| 59 | -- must know STACK_DIRECTION at compile-time | 58 | -- must know STACK_DIRECTION at compile-time |
| 60 | /* Using #error here is not wise since this file should work for | 59 | /* Using #error here is not wise since this file should work for |
| 61 | old and obscure compilers. */ | 60 | old and obscure compilers. |
| 61 | |||
| 62 | As far as I know, using it is OK if it's indented -- at least for | ||
| 63 | pcc-based processors. -- fx */ | ||
| 62 | # endif /* STACK_DIRECTION undefined */ | 64 | # endif /* STACK_DIRECTION undefined */ |
| 63 | # endif /* static */ | 65 | # endif /* static */ |
| 64 | # endif /* emacs */ | 66 | # endif /* emacs */ |
| @@ -73,38 +75,32 @@ long i00afunc (); | |||
| 73 | # define ADDRESS_FUNCTION(arg) &(arg) | 75 | # define ADDRESS_FUNCTION(arg) &(arg) |
| 74 | # endif | 76 | # endif |
| 75 | 77 | ||
| 76 | # ifdef POINTER_TYPE | 78 | # ifndef POINTER_TYPE |
| 79 | # ifdef __STDC__ | ||
| 80 | # define POINTER_TYPE void | ||
| 81 | # else | ||
| 82 | # define POINTER_TYPE char | ||
| 83 | # endif | ||
| 84 | # endif | ||
| 77 | typedef POINTER_TYPE *pointer; | 85 | typedef POINTER_TYPE *pointer; |
| 78 | # else /* not POINTER_TYPE */ | ||
| 79 | # if __STDC__ | ||
| 80 | typedef void *pointer; | ||
| 81 | # else /* not __STDC__ */ | ||
| 82 | typedef char *pointer; | ||
| 83 | # endif /* not __STDC__ */ | ||
| 84 | # endif /* not POINTER_TYPE */ | ||
| 85 | 86 | ||
| 86 | # ifndef NULL | 87 | # ifndef NULL |
| 87 | # define NULL 0 | 88 | # define NULL 0 |
| 88 | # endif | 89 | # endif |
| 89 | 90 | ||
| 90 | /* Different portions of Emacs need to call different versions of | 91 | /* The Emacs executable needs alloca to call xmalloc, because ordinary |
| 91 | malloc. The Emacs executable needs alloca to call xmalloc, because | 92 | malloc isn't protected from input signals. xmalloc also checks for |
| 92 | ordinary malloc isn't protected from input signals. On the other | 93 | out-of-memory errors, so we should use it generally. |
| 93 | hand, the utilities in lib-src need alloca to call malloc; some of | ||
| 94 | them are very simple, and don't have an xmalloc routine. | ||
| 95 | |||
| 96 | Non-Emacs programs expect this to call xmalloc. | ||
| 97 | 94 | ||
| 98 | Callers below should use malloc. */ | 95 | Callers below should use malloc. */ |
| 99 | 96 | ||
| 100 | # ifdef emacs | 97 | # undef malloc |
| 101 | # undef malloc | 98 | # define malloc xmalloc |
| 102 | # define malloc xmalloc | 99 | # undef free |
| 103 | # ifdef EMACS_FREE | 100 | # define free xfree |
| 104 | # define free EMACS_FREE | 101 | |
| 105 | # endif | 102 | void *xmalloc _P ((size_t)); |
| 106 | # endif | 103 | void xfree _P ((void *)) |
| 107 | extern pointer malloc (); | ||
| 108 | 104 | ||
| 109 | /* Define STACK_DIRECTION if you know the direction of stack | 105 | /* Define STACK_DIRECTION if you know the direction of stack |
| 110 | growth for your system; otherwise it will be automatically | 106 | growth for your system; otherwise it will be automatically |
| @@ -229,8 +225,8 @@ alloca (size) | |||
| 229 | /* Allocate combined header + user data storage. */ | 225 | /* Allocate combined header + user data storage. */ |
| 230 | 226 | ||
| 231 | { | 227 | { |
| 232 | register pointer new = malloc (sizeof (header) + size); | ||
| 233 | /* Address of header. */ | 228 | /* Address of header. */ |
| 229 | register pointer new = malloc (sizeof (header) + size); | ||
| 234 | 230 | ||
| 235 | if (new == 0) | 231 | if (new == 0) |
| 236 | abort(); | 232 | abort(); |