Sort out sphinx rules
[survex.git] / src / osalloc.h
blobd81dc125180e07649e0bb40cfd86df58b5a3bc36
1 /* osalloc.h
2 * Function prototypes for OS dep. malloc etc - funcs in error.c
3 * Copyright (C) 1996,1997,2001,2003,2004,2010 Olly Betts
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef OSALLOC_H /* only include once */
21 #define OSALLOC_H
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
27 /* define TOMBSTONES to enable tombstones on malloc blocks
28 * for bounds checking */
29 /*#define TOMBSTONES 1*/
31 #include <stdlib.h>
33 /* OSSIZE_T is to osmalloc, etc what size_t is to malloc, etc */
34 #ifndef TOMBSTONES
35 # define osfree(p) free((p))
36 # define xosmalloc(s) malloc((s))
37 # define xosrealloc(p, s) realloc((p), (s))
38 #else
39 void osfree(void *p);
40 /* ick: */
41 # define xosmalloc(s) osmalloc((s))
42 # define xosrealloc(p, s) osrealloc((p), (s))
43 #endif
44 #define OSSIZE_T size_t
46 /* NB No extra () around X as sizeof((char*)) doesn't work */
47 #define ossizeof(X) ((OSSIZE_T)sizeof(X))
48 /* Allocate like C++ new -- call osnew(<type>) eg. osnew(point) */
49 #define osnew(T) (T*)osmalloc(ossizeof(T))
51 void *osmalloc(OSSIZE_T);
52 void *osrealloc(void *, OSSIZE_T);
53 char *osstrdup(const char *str);
55 #ifdef __cplusplus
57 #endif
59 #endif