source: git/src/osalloc.h @ 0580c6a

RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-data
Last change on this file since 0580c6a was 0580c6a, checked in by Olly Betts <olly@…>, 20 years ago

Copy changes over from 1.0 branch - everything except Printing from Aven, and
Exporting CAD formats from Aven.

git-svn-id: file:///home/survex-svn/survex/branches/survex-1_1@2743 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/* osalloc.h
2 * Function prototypes for OS dep. malloc etc - funcs in error.c
3 * Copyright (C) 1996,1997,2001,2003,2004 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#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* define TOMBSTONES to enable tombstones on malloc blocks
28 * for bounds checking */
29/*#define TOMBSTONES 1*/
30
31#include <stdlib.h>
32
33#include "osdepend.h"
34
35/* OSSIZE_T is to osmalloc, etc what size_t is to malloc, etc */
36#ifdef HAVE_FAR_POINTERS
37# include "alloc.h"
38# define osfree(p) farfree((p))
39# define xosmalloc(s) farmalloc((s))
40# define xosrealloc(p, s) farrealloc((p), (s))
41# define OSSIZE_T long
42#else
43# ifndef TOMBSTONES
44#  define osfree(p) free((p))
45#  define xosmalloc(s) malloc((s))
46#  define xosrealloc(p, s) realloc((p), (s))
47# else
48void osfree(void *p);
49/* ick: */
50#  define xosmalloc(s) osmalloc((s))
51#  define xosrealloc(p, s) osrealloc((p), (s))
52# endif
53# define OSSIZE_T size_t
54#endif
55
56/* NB No extra () around X as sizeof((char*)) doesn't work */
57#define ossizeof(X) ((OSSIZE_T)sizeof(X))
58/* Allocate like C++ new -- call osnew(<type>) eg. osnew(point) */
59#define osnew(T) (T*)osmalloc(ossizeof(T))
60
61void Far *osmalloc(OSSIZE_T);
62void Far *osrealloc(void *, OSSIZE_T);
63char Far *osstrdup(const char *str);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif
Note: See TracBrowser for help on using the repository browser.