Haru Free PDF Library
hpdf_mmgr.h
Go to the documentation of this file.
1 /*
2  * << Haru Free PDF Library >> -- hpdf_mmgr.h
3  *
4  * URL: http://libharu.org
5  *
6  * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7  * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
8  *
9  * Permission to use, copy, modify, distribute and sell this software
10  * and its documentation for any purpose is hereby granted without fee,
11  * provided that the above copyright notice appear in all copies and
12  * that both that copyright notice and this permission notice appear
13  * in supporting documentation.
14  * It is provided "as is" without express or implied warranty.
15  *
16  */
17 
18 #ifndef _HPDF_MMGR_H
19 #define _HPDF_MMGR_H
20 
21 #include "hpdf_types.h"
22 #include "hpdf_error.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
29 
30 typedef struct _HPDF_MPool_Node_Rec {
36 
37 
38 typedef struct _HPDF_MMgr_Rec *HPDF_MMgr;
39 
40 typedef struct _HPDF_MMgr_Rec {
46 
47 #ifdef HPDF_MEM_DEBUG
48  HPDF_UINT alloc_cnt;
49  HPDF_UINT free_cnt;
50 #endif
52 
53 
54 /* HPDF_mpool_new
55  *
56  * create new HPDF_mpool object. when memory allocation goes wrong,
57  * it returns NULL and error handling function will be called.
58  * if buf_size is non-zero, mmgr is configured to be using memory-pool
59  */
62  HPDF_UINT buf_size,
63  HPDF_Alloc_Func alloc_fn,
64  HPDF_Free_Func free_fn);
65 
66 
67 void
69 
70 
71 void*
73  HPDF_UINT size);
74 
75 
76 void
78  void *aptr);
79 
80 #ifdef __cplusplus
81 }
82 #endif /* __cplusplus */
83 
84 #endif /* _HPDF_MMGR_H */
85 
struct _HPDF_MMgr_Rec HPDF_MMgr_Rec
HPDF_MMgr HPDF_MMgr_New(HPDF_Error error, HPDF_UINT buf_size, HPDF_Alloc_Func alloc_fn, HPDF_Free_Func free_fn)
struct _HPDF_MMgr_Rec * HPDF_MMgr
Definition: hpdf_mmgr.h:38
void HPDF_FreeMem(HPDF_MMgr mmgr, void *aptr)
void * HPDF_GetMem(HPDF_MMgr mmgr, HPDF_UINT size)
void HPDF_MMgr_Free(HPDF_MMgr mmgr)
struct _HPDF_MPool_Node_Rec * HPDF_MPool_Node
Definition: hpdf_mmgr.h:28
struct _HPDF_MPool_Node_Rec HPDF_MPool_Node_Rec
void(HPDF_STDCALL * HPDF_Free_Func)(void *aptr)
Definition: hpdf_types.h:209
unsigned int HPDF_UINT
Definition: hpdf_types.h:45
void *(HPDF_STDCALL * HPDF_Alloc_Func)(HPDF_UINT size)
Definition: hpdf_types.h:205
unsigned char HPDF_BYTE
Definition: hpdf_types.h:74
Definition: hpdf_error.h:180
Definition: hpdf_mmgr.h:40
HPDF_Error error
Definition: hpdf_mmgr.h:41
HPDF_MPool_Node mpool
Definition: hpdf_mmgr.h:44
HPDF_UINT buf_size
Definition: hpdf_mmgr.h:45
HPDF_Alloc_Func alloc_fn
Definition: hpdf_mmgr.h:42
HPDF_Free_Func free_fn
Definition: hpdf_mmgr.h:43
Definition: hpdf_mmgr.h:30
HPDF_MPool_Node next_node
Definition: hpdf_mmgr.h:34
HPDF_BYTE * buf
Definition: hpdf_mmgr.h:31
HPDF_UINT used_size
Definition: hpdf_mmgr.h:33
HPDF_UINT size
Definition: hpdf_mmgr.h:32