From 1aef1c5921c5c339057b71f3c6cdc8d4b35a73f6 Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 1 Nov 1990 09:32:21 +0000 Subject: [PATCH] Added high-speed clear loops and changed behaviour of Realloc --- modules/src/alloc/Realloc.c | 5 ++++- modules/src/alloc/alloc.3 | 3 ++- modules/src/alloc/clear.c | 12 ++++++++++++ modules/src/alloc/st_alloc.c | 11 +++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/src/alloc/Realloc.c b/modules/src/alloc/Realloc.c index 527b5268e..76e24d9e7 100644 --- a/modules/src/alloc/Realloc.c +++ b/modules/src/alloc/Realloc.c @@ -17,7 +17,10 @@ Realloc(ptr, sz) char ptr[]; unsigned int sz; { - register char *mptr = realloc(ptr, sz); + register char *mptr; + + if (!ptr) mptr = malloc(sz); + else mptr = realloc(ptr, sz); if (sz && mptr == 0) No_Mem(); return mptr; } diff --git a/modules/src/alloc/alloc.3 b/modules/src/alloc/alloc.3 index b79d2704e..31d0cd9f5 100644 --- a/modules/src/alloc/alloc.3 +++ b/modules/src/alloc/alloc.3 @@ -56,7 +56,8 @@ bytes, initialized with the null-terminated string \fIstr\fR. .PP \fIRealloc\fR changes the size of the block at \fIbuf\fR to \fIsize\fR bytes, and returns a pointer to the -(possibly moved) block. +(possibly moved) block. If \fIbuf\fP is a null pointer, \fIRealloc\fP +behaves as \fIMalloc\fP. .PP \fISrealloc\fR reallocates the string at \fIstr\fR to \fIsize\fR bytes. diff --git a/modules/src/alloc/clear.c b/modules/src/alloc/clear.c index d6bce4238..996af5343 100644 --- a/modules/src/alloc/clear.c +++ b/modules/src/alloc/clear.c @@ -13,6 +13,18 @@ clear(ptr, n) { register long *q = (long *) ptr; + while (n >= 8*sizeof (long)) { + /* high-speed clear loop */ + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + n -= 8*sizeof (long); + } while (n >= sizeof (long)) { /* high-speed clear loop */ *q++ = 0; diff --git a/modules/src/alloc/st_alloc.c b/modules/src/alloc/st_alloc.c index b8c6927b6..ad469dff8 100644 --- a/modules/src/alloc/st_alloc.c +++ b/modules/src/alloc/st_alloc.c @@ -37,6 +37,17 @@ st_alloc(phead, size, count) *phead = (char *) (((_PALLOC_)p)->_A_next); retval = p; q = (long *) p; + while (size >= 8*sizeof(long)) { + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + *q++ = 0; + size -= 8*sizeof(long); + } while (size >= sizeof(long)) { *q++ = 0; size -= sizeof(long); -- 2.34.1