diff options
author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-04-07 06:19:22 +0000 |
---|---|---|
committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-04-07 06:19:22 +0000 |
commit | eba7624af00052f697e82c0a3e6d72a77d0675e8 (patch) | |
tree | 622e4cfaa55688a107b4c8e1108af0298ec9754b /gcc/cppalloc.c | |
parent | 3b1e673ed387fd429c18f9eeff47a0cdcbab85ed (diff) | |
download | gcc-eba7624af00052f697e82c0a3e6d72a77d0675e8.tar.gz |
* cppalloc.c (xcalloc): Re-implement using calloc, rather than malloc+bzero.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@9319 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppalloc.c')
-rw-r--r-- | gcc/cppalloc.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/gcc/cppalloc.c b/gcc/cppalloc.c index aa37aac25b5..2287dbcb4c4 100644 --- a/gcc/cppalloc.c +++ b/gcc/cppalloc.c @@ -45,10 +45,9 @@ xrealloc (old, size) unsigned size; { register char *ptr = (char *) realloc (old, size); - if (ptr != 0) return (ptr); - memory_full (); - /*NOTREACHED*/ - return 0; + if (ptr == 0) + memory_full (); + return ptr; } char * @@ -56,26 +55,8 @@ xcalloc (number, size) unsigned number, size; { register unsigned total = number * size; - register char *ptr = (char *) malloc (total); - if (ptr != 0) { - if (total > 100) - bzero (ptr, total); - else { - /* It's not too long, so loop, zeroing by longs. - It must be safe because malloc values are always well aligned. */ - register long *zp = (long *) ptr; - register long *zl = (long *) (ptr + total - 4); - register int i = total - 4; - while (zp < zl) - *zp++ = 0; - if (i < 0) - i = 0; - while (i < total) - ptr[i++] = 0; - } - return ptr; - } - memory_full (); - /*NOTREACHED*/ - return 0; + register char *ptr = (char *) calloc (number, size); + if (ptr == 0) + memory_full (); + return ptr; } |