OLD | NEW |
| (Empty) |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
5 | |
6 #ifndef PLARENAS_H | |
7 #define PLARENAS_H | |
8 | |
9 PR_BEGIN_EXTERN_C | |
10 | |
11 typedef struct PLArenaPool PLArenaPool; | |
12 | |
13 /* | |
14 ** Initialize an arena pool with the given name for debugging and metering, | |
15 ** with a minimum gross size per arena of size bytes. The net size per arena | |
16 ** is smaller than the gross size by a header of four pointers plus any | |
17 ** necessary padding for alignment. | |
18 ** | |
19 ** Note: choose a gross size that's a power of two to avoid the heap allocator | |
20 ** rounding the size up. | |
21 **/ | |
22 PR_EXTERN(void) PL_InitArenaPool( | |
23 PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align); | |
24 | |
25 /* | |
26 ** Finish using arenas, freeing all memory associated with them. | |
27 **/ | |
28 PR_EXTERN(void) PL_ArenaFinish(void); | |
29 | |
30 /* | |
31 ** Free the arenas in pool. The user may continue to allocate from pool | |
32 ** after calling this function. There is no need to call PL_InitArenaPool() | |
33 ** again unless PL_FinishArenaPool(pool) has been called. | |
34 **/ | |
35 PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool); | |
36 | |
37 /* | |
38 ** Free the arenas in pool and finish using it altogether. | |
39 **/ | |
40 PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool); | |
41 | |
42 /* | |
43 ** Compact all of the arenas in a pool so that no space is wasted. | |
44 ** NOT IMPLEMENTED. Do not use. | |
45 **/ | |
46 PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool); | |
47 | |
48 /* | |
49 ** Friend functions used by the PL_ARENA_*() macros. | |
50 **/ | |
51 PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb); | |
52 | |
53 PR_EXTERN(void *) PL_ArenaGrow( | |
54 PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr); | |
55 | |
56 PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark); | |
57 | |
58 /* | |
59 ** memset contents of all arenas in pool to pattern | |
60 */ | |
61 PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern); | |
62 | |
63 PR_END_EXTERN_C | |
64 | |
65 #endif /* PLARENAS_H */ | |
OLD | NEW |