[421b7d2] | 1 | /* osalloc.h |
---|
[64d37a3] | 2 | * Function prototypes for OS dep. malloc etc - funcs in error.c |
---|
[9965b2b] | 3 | * Copyright (C) 1996,1997,2001,2003,2004,2010 Olly Betts |
---|
[846746e] | 4 | * |
---|
[89231c4] | 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. |
---|
[846746e] | 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 |
---|
[89231c4] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | * GNU General Public License for more details. |
---|
[846746e] | 14 | * |
---|
[89231c4] | 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 |
---|
[ecbc6c18] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[d1b1380] | 18 | */ |
---|
| 19 | |
---|
| 20 | #ifndef OSALLOC_H /* only include once */ |
---|
| 21 | #define OSALLOC_H |
---|
| 22 | |
---|
[0580c6a] | 23 | #ifdef __cplusplus |
---|
| 24 | extern "C" { |
---|
| 25 | #endif |
---|
| 26 | |
---|
[a420b49] | 27 | /* define TOMBSTONES to enable tombstones on malloc blocks |
---|
| 28 | * for bounds checking */ |
---|
| 29 | /*#define TOMBSTONES 1*/ |
---|
| 30 | |
---|
[2279602] | 31 | #include <stdlib.h> |
---|
| 32 | |
---|
[d1b1380] | 33 | #include "osdepend.h" |
---|
| 34 | |
---|
| 35 | /* OSSIZE_T is to osmalloc, etc what size_t is to malloc, etc */ |
---|
[9965b2b] | 36 | #ifndef TOMBSTONES |
---|
| 37 | # define osfree(p) free((p)) |
---|
| 38 | # define xosmalloc(s) malloc((s)) |
---|
| 39 | # define xosrealloc(p, s) realloc((p), (s)) |
---|
[d1b1380] | 40 | #else |
---|
[a9f5117] | 41 | void osfree(void *p); |
---|
[a420b49] | 42 | /* ick: */ |
---|
[9965b2b] | 43 | # define xosmalloc(s) osmalloc((s)) |
---|
| 44 | # define xosrealloc(p, s) osrealloc((p), (s)) |
---|
[d1b1380] | 45 | #endif |
---|
[9965b2b] | 46 | #define OSSIZE_T size_t |
---|
[d1b1380] | 47 | |
---|
| 48 | /* NB No extra () around X as sizeof((char*)) doesn't work */ |
---|
| 49 | #define ossizeof(X) ((OSSIZE_T)sizeof(X)) |
---|
[64d37a3] | 50 | /* Allocate like C++ new -- call osnew(<type>) eg. osnew(point) */ |
---|
[d1b1380] | 51 | #define osnew(T) (T*)osmalloc(ossizeof(T)) |
---|
| 52 | |
---|
[9965b2b] | 53 | void *osmalloc(OSSIZE_T); |
---|
| 54 | void *osrealloc(void *, OSSIZE_T); |
---|
| 55 | char *osstrdup(const char *str); |
---|
[d1b1380] | 56 | |
---|
[0580c6a] | 57 | #ifdef __cplusplus |
---|
| 58 | } |
---|
| 59 | #endif |
---|
| 60 | |
---|
[d1b1380] | 61 | #endif |
---|