c3dde03353e2615dabda741db25e4fea6c1daaf0
[platform/upstream/fribidi.git] / lib / mem.h
1 /* FriBidi
2  * mem.h - memory manipulation routines
3  *
4  * $Id: mem.h,v 1.7 2006-01-31 03:23:13 behdad Exp $
5  * $Author: behdad $
6  * $Date: 2006-01-31 03:23:13 $
7  * $Revision: 1.7 $
8  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/mem.h,v $
9  *
10  * Author:
11  *   Behdad Esfahbod, 2001, 2002, 2004
12  *
13  * Copyright (C) 2004 Sharif FarsiWeb, Inc
14  * Copyright (C) 2001,2002 Behdad Esfahbod
15  * 
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  * 
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * Lesser General Public License for more details.
25  * 
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with this library, in a file named COPYING; if not, write to the
28  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29  * Boston, MA 02110-1301, USA
30  * 
31  * For licensing issues, contact <license@farsiweb.info>.
32  */
33 #ifndef _MEM_H
34 #define _MEM_H
35
36 #include "common.h"
37
38 #include <fribidi-types.h>
39
40 #include <fribidi-begindecls.h>
41
42 #if FRIBIDI_USE_GLIB+0
43
44 #ifndef __FRIBIDI_DOC
45 # include <glib/gmem.h>
46 #endif /* !__FRIBIDI_DOC */
47
48 #define FriBidiMemChunk GMemChunk
49 #define FRIBIDI_ALLOC_ONLY G_ALLOC_ONLY
50 #define fribidi_mem_chunk_new g_mem_chunk_new
51 #define fribidi_mem_chunk_alloc g_mem_chunk_alloc
52 #define fribidi_mem_chunk_destroy g_mem_chunk_destroy
53
54 #else /* !FRIBIDI_USE_GLIB */
55
56 typedef struct _FriBidiMemChunk FriBidiMemChunk;
57
58 #define FRIBIDI_ALLOC_ONLY      1
59
60 #define fribidi_mem_chunk_new FRIBIDI_PRIVATESPACE(mem_chunk_new)
61 FriBidiMemChunk *
62 fribidi_mem_chunk_new (
63   const char *name,
64   int atom_size,
65   unsigned long area_size,
66   int alloc_type
67 )
68      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_MALLOC FRIBIDI_GNUC_WARN_UNUSED;
69
70 #define fribidi_mem_chunk_alloc FRIBIDI_PRIVATESPACE(mem_chunk_alloc)
71      void *fribidi_mem_chunk_alloc (
72   FriBidiMemChunk *mem_chunk
73 )
74      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_MALLOC FRIBIDI_GNUC_WARN_UNUSED;
75
76 #define fribidi_mem_chunk_destroy FRIBIDI_PRIVATESPACE(mem_chunk_destroy)
77      void fribidi_mem_chunk_destroy (
78   FriBidiMemChunk *mem_chunk
79 ) FRIBIDI_GNUC_HIDDEN;
80
81 #endif /* !FRIBIDI_USE_GLIB */
82
83 #define fribidi_chunk_new(type, chunk)        ( \
84                 (type *) fribidi_mem_chunk_alloc (chunk) \
85         )
86
87 #define fribidi_chunk_new_for_type(type) ( \
88                 fribidi_mem_chunk_new(FRIBIDI, sizeof (type), \
89                                 FRIBIDI_CHUNK_SIZE, FRIBIDI_ALLOC_ONLY) \
90         )
91
92 #include <fribidi-enddecls.h>
93
94 #endif /* !_MEM_H */
95 /* Editor directions:
96  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
97  */