2
* Copyright 1999-2004 The Apache Software Foundation
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
/***************************************************************************
18
* Description: Memory Pool object header file *
19
* Author: Gal Shachor <shachor@il.ibm.com> *
20
* Version: $Revision: 1.10 $ *
21
***************************************************************************/
25
#include "jk_global.h"
30
#endif /* __cplusplus */
34
* @brief Jk memory allocation
36
* Similar with apr_pools, but completely unsynchronized.
42
* The pool atom (basic pool alocation unit) is an 8 byte long.
43
* Each allocation (even for 1 byte) will return a round up to the
46
* This is to help in alignment of 32/64 bit machines ...
50
typedef __int64 jk_pool_atom_t;
52
typedef long long jk_pool_atom_t;
53
#elif defined(SOLARIS)
54
typedef long long jk_pool_atom_t;
56
typedef long long jk_pool_atom_t;
57
#elif defined(FREEBSD)
58
typedef long long jk_pool_atom_t;
60
typedef long long jk_pool_atom_t;
61
#elif defined(NETWARE)
62
typedef long long jk_pool_atom_t;
64
typedef long long jk_pool_atom_t;
66
typedef long long jk_pool_atom_t;
68
typedef void *jk_pool_atom_t;
70
typedef long long jk_pool_atom_t;
77
/* JK_ALIGN() is only to be used to align on a power of 2 boundary */
78
#define JK_ALIGN(size, boundary) \
79
(((size) + ((boundary) - 1)) & ~((boundary) - 1))
81
/** Default alignment */
83
#define JK_ALIGN_DEFAULT(size) JK_ALIGN(size, 16)
85
#define JK_ALIGN_DEFAULT(size) JK_ALIGN(size, 8)
89
* Pool size in number of pool atoms.
91
#define TINY_POOL_SIZE 256 /* Tiny 1/4K atom pool. */
92
#define SMALL_POOL_SIZE 512 /* Small 1/2K atom pool. */
93
#define BIG_POOL_SIZE 2*SMALL_POOL_SIZE /* Bigger 1K atom pool. */
94
#define HUGE_POOL_SIZE 2*BIG_POOL_SIZE /* Huge 2K atom pool. */
96
/** jk pool structure */
107
typedef struct jk_pool jk_pool_t;
109
void jk_open_pool(jk_pool_t *p, jk_pool_atom_t *buf, size_t size);
111
void jk_close_pool(jk_pool_t *p);
113
void jk_reset_pool(jk_pool_t *p);
115
void *jk_pool_alloc(jk_pool_t *p, size_t sz);
117
void *jk_pool_realloc(jk_pool_t *p,
118
size_t sz, const void *old, size_t old_sz);
120
void *jk_pool_strdup(jk_pool_t *p, const char *s);
124
#endif /* __cplusplus */
125
#endif /* _JK_POOL_H */