source: git/src/osalloc.h @ fc4b814

RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-datawalls-data-hanging-as-warning
Last change on this file since fc4b814 was 64d37a3, checked in by Olly Betts <olly@…>, 20 years ago

Sync with 1.0 branch.

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

  • Property mode set to 100644
File size: 1.9 KB
Line 
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
44void 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
57void Far *osmalloc(OSSIZE_T);
58void Far *osrealloc(void *, OSSIZE_T);
59char Far *osstrdup(const char *str);
60
61#endif
Note: See TracBrowser for help on using the repository browser.