ack/modules/src/alloc/clear.c

36 lines
698 B
C
Raw Normal View History

1987-03-10 09:24:02 +00:00
/* $Header$ */
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.
*/
/* instead of Calloc: */
clear(ptr, n)
register char *ptr;
register unsigned int n;
1987-01-05 14:44:25 +00:00
{
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);
}
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';
}