summaryrefslogtreecommitdiff
path: root/fribidi_mem.h
blob: 9500af484cb3bed377afad83054a669c64d2aa3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* FriBidi - Library of BiDi algorithm
 * Copyright (C) 2001,2002 Behdad Esfahbod.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser FriBidieneral Public  
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,  
 * but WITHOUT ANY WARRANTY; without even the implied warranty of   
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser FriBidieneral Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser FriBidieneral Public License  
 * along with this library, in a file named COPYING; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA
 * 
 * For licensing issues, contact <fwpg@sharif.edu>.
 */

#ifndef FRIBIDI_MEM_H
#define FRIBIDI_MEM_H

#include "fribidi_config.h"
#include "fribidi_types.h"

#ifdef __cplusplus
extern "C"
{
#endif

  FriBidiList *fribidi_list_append (FriBidiEnv *fribidienv,
				    FriBidiList *list,
				    void *data);

  typedef struct _FriBidiMemChunk FriBidiMemChunk;

#define FRIBIDI_ALLOC_ONLY      1
#define FRIBIDI_ALLOC_AND_FREE  2

  FriBidiMemChunk *fribidi_mem_chunk_new (FriBidiEnv *fribidienv,
					  char *name,
					  int atom_size,
					  unsigned long area_size,
					  int type);
  void fribidi_mem_chunk_destroy (FriBidiEnv *fribidienv,
				  FriBidiMemChunk *mem_chunk);
  void *fribidi_mem_chunk_alloc (FriBidiEnv *fribidienv,
				 FriBidiMemChunk *mem_chunk);
  void *fribidi_mem_chunk_alloc0 (FriBidiEnv *fribidienv,
				  FriBidiMemChunk *mem_chunk);
  void fribidi_mem_chunk_free (FriBidiEnv *fribidienv,
			       FriBidiMemChunk *mem_chunk,
			       void *mem);

#define fribidi_mem_chunk_create(fbenv, type, pre_alloc, alloc_type) ( \
  fribidi_mem_chunk_new (fbenv, \
                   #type " mem chunks (" #pre_alloc ")", \
                   sizeof (type), \
                   sizeof (type) * (pre_alloc), \
                   (alloc_type)) \
)
#define fribidi_chunk_new(fbenv, type, chunk)        ( \
  (type *) fribidi_mem_chunk_alloc (fbenv, chunk) \
)

#ifdef	__cplusplus
}
#endif

#endif				/* FRIBIDI_MEM_H */