Pristine Ack-5.5
[Ack-5.5.git] / modules / src / alloc / clear.c
1 /* $Id: clear.c,v 1.10 1994/06/24 11:06:41 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /*      clear - clear a block of memory, and try to do it fast.
7 */
8
9 #include "alloc.h"
10
11 /* instead of Calloc: */
12
13 void
14 clear(ptr, n)
15         register char *ptr;
16         register unsigned int n;
17 {
18         register long *q = (long *) ptr;
19
20         while (n >= 8*sizeof (long))    {
21                         /* high-speed clear loop */
22                 *q++ = 0;
23                 *q++ = 0;
24                 *q++ = 0;
25                 *q++ = 0;
26                 *q++ = 0;
27                 *q++ = 0;
28                 *q++ = 0;
29                 *q++ = 0;
30                 n -= 8*sizeof (long);
31         }
32         while (n >= sizeof (long))      {
33                         /* high-speed clear loop */
34                 *q++ = 0;
35                 n -= sizeof (long);
36         }
37         ptr = (char *) q;
38         while (n--) *ptr++ = '\0';
39 }