Pristine Ack-5.5
[Ack-5.5.git] / util / int / alloc.c
1 /* $Id: alloc.c,v 2.3 1994/06/24 10:45:37 ceriel Exp $ */
2
3 #include        "debug.h"
4 #include        "global.h"
5 #include        "alloc.h"
6
7 extern char *malloc();
8 extern char *realloc();
9
10 char *Malloc(sz, descr)
11         size sz;
12         char *descr;
13 {
14         register char *new = malloc((unsigned int) (sz));
15         
16         if (new == (char *) 0 && descr != (char *) 0)
17                 fatal("Cannot allocate %s", descr);
18
19 #ifdef  DB_MALLOC                       /* from debug.h */
20         /* fill area with recognizable garbage */
21         {       register char *p = new;
22                 register size i = sz;
23                 register char ch = 0252;
24
25                 if (p) {
26                         while (i--) {
27                                 *p++ = ch;
28                                 ch = ~ch;
29                         }
30                 }
31         }
32 #endif  /* DB_MALLOC */
33
34         return new;
35 }
36
37 char *Realloc(old, sz, descr)
38         char *old;
39         size sz;
40         char *descr;
41 {
42         register char *new = realloc(old, (unsigned int) (sz));
43         
44         if (new == (char *) 0)
45                 fatal("Cannot reallocate %s", descr);
46         return new;
47 }
48