PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/FreeImage/Source/LibMNG/libmng_memory.h

https://bitbucket.org/cabalistic/ogredeps/
C++ Header | 64 lines | 20 code | 8 blank | 36 comment | 9 complexity | 6fbdb4c919187dd5c6e8a5f9cbdcbcbb MD5 | raw file
 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/* ************************************************************************** */