Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/support/myalloc.h @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * myalloc.h - memory management wrappers | |
7 */ | |
8 | |
9 #ifndef MYALLOC_H | |
10 #define MYALLOC_H | |
11 | |
12 //#include <malloc.h> | |
13 | |
14 void *myalloc(unsigned n); | |
15 void *myzalloc(unsigned n, unsigned size); | |
16 void myfree(void *ptr, const char *file, int line); | |
17 void *myrealloc(void *p, unsigned n, const char *file, int line); | |
18 void ptr_ng(const void *ptr, const char *file, int line); | |
19 int ptr_ok(void *ptr); | |
20 void size_ok(const void *ptr, unsigned, const char *file, int line); | |
21 char *mystrdup(const char *); | |
22 | |
23 #define ALLOCATE(n,type) ((type *) myalloc( (n) *sizeof(type) ) ) | |
24 | |
25 #define ALLOCATE_ST(p, n) (*(void **)(&p) = myalloc( (n)*sizeof(*(p)) )) | |
26 | |
27 #define ZALLOCATE(n,type) ((type *) myzalloc( (n) , sizeof(type) ) ) | |
28 | |
29 #define ZALLOCATE_ST(p, n) (*(void **)(&p) = myzalloc( (n), sizeof(*(p)) )) | |
30 | |
31 #define reallocate(a,n,type) ((type *) myrealloc((a),(n)*sizeof(type), __FILE__, __LINE__)) | |
32 | |
33 #define REALLOCATE_ST(p, n) (*(void **)(&p) = myrealloc((p), (n)*sizeof(*(p)) , __FILE__, __LINE__)) | |
34 | |
35 #define ok_ptr(p) ptr_ng(p, __FILE__, __LINE__) | |
36 #define DEALLOCATE(x) myfree(x, __FILE__, __LINE__) | |
37 | |
38 | |
39 #endif /* MYALLOC_H */ |