1 | /* osalloc.h |
---|
2 | * Function prototypes for OS dep. malloc etc - funcs in error.c |
---|
3 | * Copyright (C) 1996,1997,2001,2003 Olly Betts |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU General Public License as published by |
---|
7 | * the Free Software Foundation; either version 2 of the License, or |
---|
8 | * (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License |
---|
16 | * along with this program; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef OSALLOC_H /* only include once */ |
---|
21 | #define OSALLOC_H |
---|
22 | |
---|
23 | /* define TOMBSTONES to enable tombstones on malloc blocks |
---|
24 | * for bounds checking */ |
---|
25 | /*#define TOMBSTONES 1*/ |
---|
26 | |
---|
27 | #include <stdlib.h> |
---|
28 | |
---|
29 | #include "osdepend.h" |
---|
30 | |
---|
31 | /* OSSIZE_T is to osmalloc, etc what size_t is to malloc, etc */ |
---|
32 | #ifdef HAVE_FAR_POINTERS |
---|
33 | # include "alloc.h" |
---|
34 | # define osfree(p) farfree((p)) |
---|
35 | # define xosmalloc(s) farmalloc((s)) |
---|
36 | # define xosrealloc(p, s) farrealloc((p), (s)) |
---|
37 | # define OSSIZE_T long |
---|
38 | #else |
---|
39 | # ifndef TOMBSTONES |
---|
40 | # define osfree(p) free((p)) |
---|
41 | # define xosmalloc(s) malloc((s)) |
---|
42 | # define xosrealloc(p, s) realloc((p), (s)) |
---|
43 | # else |
---|
44 | void osfree(void *p); |
---|
45 | /* ick: */ |
---|
46 | # define xosmalloc(s) osmalloc((s)) |
---|
47 | # define xosrealloc(p, s) osrealloc((p), (s)) |
---|
48 | # endif |
---|
49 | # define OSSIZE_T size_t |
---|
50 | #endif |
---|
51 | |
---|
52 | /* NB No extra () around X as sizeof((char*)) doesn't work */ |
---|
53 | #define ossizeof(X) ((OSSIZE_T)sizeof(X)) |
---|
54 | /* Allocate like C++ new -- call osnew(<type>) eg. osnew(point) */ |
---|
55 | #define osnew(T) (T*)osmalloc(ossizeof(T)) |
---|
56 | |
---|
57 | void Far *osmalloc(OSSIZE_T); |
---|
58 | void Far *osrealloc(void *, OSSIZE_T); |
---|
59 | char Far *osstrdup(const char *str); |
---|
60 | |
---|
61 | #endif |
---|