1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1987-03-09 15:15:03 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1987-01-05 14:44:25 +00:00
|
|
|
/* clear - clear a block of memory, and try to do it fast.
|
|
|
|
*/
|
|
|
|
|
1992-12-04 09:36:54 +00:00
|
|
|
#include "alloc.h"
|
|
|
|
|
1987-01-05 14:44:25 +00:00
|
|
|
/* instead of Calloc: */
|
1992-12-04 09:36:54 +00:00
|
|
|
|
|
|
|
void
|
1987-01-05 14:44:25 +00:00
|
|
|
clear(ptr, n)
|
|
|
|
register char *ptr;
|
1987-05-18 14:16:41 +00:00
|
|
|
register unsigned int n;
|
1987-01-05 14:44:25 +00:00
|
|
|
{
|
|
|
|
register long *q = (long *) ptr;
|
|
|
|
|
1990-11-01 09:32:21 +00:00
|
|
|
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);
|
|
|
|
}
|
1987-01-05 14:44:25 +00:00
|
|
|
while (n >= sizeof (long)) {
|
|
|
|
/* high-speed clear loop */
|
|
|
|
*q++ = 0;
|
|
|
|
n -= sizeof (long);
|
|
|
|
}
|
|
|
|
ptr = (char *) q;
|
|
|
|
while (n--) *ptr++ = '\0';
|
|
|
|
}
|