1/*************************************************************************/
2/* */
3/* Language Technologies Institute */
4/* Carnegie Mellon University */
5/* Copyright (c) 1999 */
6/* All Rights Reserved. */
7/* */
8/* Permission is hereby granted, free of charge, to use and distribute */
9/* this software and its documentation without restriction, including */
10/* without limitation the rights to use, copy, modify, merge, publish, */
11/* distribute, sublicense, and/or sell copies of this work, and to */
12/* permit persons to whom this work is furnished to do so, subject to */
13/* the following conditions: */
14/* 1. The code must retain the above copyright notice, this list of */
15/* conditions and the following disclaimer. */
16/* 2. Any modifications must be clearly marked as such. */
17/* 3. Original authors' names are not deleted. */
18/* 4. The authors' names are not used to endorse or promote products */
19/* derived from this software without specific prior written */
20/* permission. */
21/* */
22/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30/* THIS SOFTWARE. */
31/* */
32/*************************************************************************/
33/* Author: Alan W Black (awb@cs.cmu.edu) */
34/* Date: July 1999 */
35/*************************************************************************/
36/* */
37/* Basic wraparounds for malloc and free */
38/* */
39/*************************************************************************/
40#ifndef __CST_ALLOC_H__
41#define __CST_ALLOC_H__
42
43#ifndef TRUE
44#define TRUE (1==1)
45#endif
46#ifndef FALSE
47#define FALSE (1==0)
48#endif
49
50/* Global allocation (the only kind on Unix) */
51void *cst_safe_alloc(int size);
52void *cst_safe_calloc(int size);
53void *cst_safe_realloc(void *p,int size);
54
55/* Allocate on local heap (needed on WinCE for various reasons) */
56#ifdef UNDER_CE
57#include <windows.h>
58typedef HANDLE cst_alloc_context;
59
60cst_alloc_context new_alloc_context(int size);
61void delete_alloc_context(cst_alloc_context ctx);
62
63void *cst_local_alloc(cst_alloc_context ctx, int size);
64void cst_local_free(cst_alloc_context ctx, void *p);
65#else /* not UNDER_CE */
66typedef void * cst_alloc_context;
67#define new_alloc_context(size) (NULL)
68#define delete_alloc_context(ctx)
69#define cst_local_alloc(ctx,size) cst_safe_alloc(size)
70#define cst_local_free(cst,p) cst_free(p)
71#endif /* UNDER_CE */
72
73/* The public interface to the alloc functions */
74
75/* Note the underlying call is calloc, so everything is zero'd */
76#define cst_alloc(TYPE,SIZE) ((TYPE *)cst_safe_alloc(sizeof(TYPE)*(SIZE)))
77#define cst_calloc(TYPE,SIZE) ((TYPE *)cst_safe_calloc(sizeof(TYPE)*(SIZE)))
78#define cst_realloc(P,TYPE,SIZE) ((TYPE *)cst_safe_realloc((void *)(P),sizeof(TYPE)*(SIZE)))
79
80void cst_free(void *p);
81
82#endif
83

source code of include/flite/cst_alloc.h