source: trunk/src/3rdparty/libmng/libmng_memory.h@ 122

Last change on this file since 122 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 3.8 KB
Line 
1/* ************************************************************************** */
2/* * For conditions of distribution and use, * */
3/* * see copyright notice in libmng.h * */
4/* ************************************************************************** */
5/* * * */
6/* * project : libmng * */
7/* * file : libmng_memory.h copyright (c) 2000-2003 G.Juyn * */
8/* * version : 1.0.0 * */
9/* * * */
10/* * purpose : Memory management (definition) * */
11/* * * */
12/* * author : G.Juyn * */
13/* * * */
14/* * comment : Definition of memory management functions * */
15/* * * */
16/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
17/* * - changed strict-ANSI stuff * */
18/* * * */
19/* * 0.5.3 - 06/12/2000 - G.Juyn * */
20/* * - swapped MNG_COPY parameter-names * */
21/* * 0.5.3 - 06/27/2000 - G.Juyn * */
22/* * - changed size parameter to mng_size_t * */
23/* * * */
24/* * 0.9.2 - 08/05/2000 - G.Juyn * */
25/* * - changed file-prefixes * */
26/* * * */
27/* ************************************************************************** */
28
29#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
30#pragma option -A /* force ANSI-C */
31#endif
32
33#ifndef _libmng_memory_h_
34#define _libmng_memory_h_
35
36/* ************************************************************************** */
37/* * * */
38/* * Generic memory manager macros * */
39/* * * */
40/* ************************************************************************** */
41
42#ifdef MNG_INTERNAL_MEMMNGMT
43#define MNG_ALLOC(H,P,L) { P = calloc (1, (mng_size_t)(L)); \
44 if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } }
45#define MNG_ALLOCX(H,P,L) { P = calloc (1, (mng_size_t)(L)); }
46#define MNG_FREE(H,P,L) { if (P) { free (P); P = 0; } }
47#define MNG_FREEX(H,P,L) { if (P) free (P); }
48#else
49#define MNG_ALLOC(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); \
50 if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } }
51#define MNG_ALLOCX(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); }
52#define MNG_FREE(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); P = 0; } }
53#define MNG_FREEX(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); } }
54#endif /* mng_internal_memmngmt */
55
56#define MNG_COPY(D,S,L) { memcpy (D, S, (mng_size_t)(L)); }
57
58/* ************************************************************************** */
59
60#endif /* _libmng_memory_h_ */
61
62/* ************************************************************************** */
63/* * end of file * */
64/* ************************************************************************** */
Note: See TracBrowser for help on using the repository browser.