2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 /***************************************************************************
19 * Description: Memory Pool object header file *
20 * Author: Gal Shachor <shachor@il.ibm.com> *
21 * Version: $Revision: 466585 $ *
22 ***************************************************************************/
26 #include "jk_global.h"
31 #endif /* __cplusplus */
35 * @brief Jk memory allocation
37 * Similar with apr_pools, but completely unsynchronized.
43 * The pool atom (basic pool alocation unit) is an 8 byte long.
44 * Each allocation (even for 1 byte) will return a round up to the
47 * This is to help in alignment of 32/64 bit machines ...
51 typedef __int64 jk_pool_atom_t;
53 typedef long long jk_pool_atom_t;
54 #elif defined(SOLARIS)
55 typedef long long jk_pool_atom_t;
57 typedef long long jk_pool_atom_t;
58 #elif defined(FREEBSD)
59 typedef long long jk_pool_atom_t;
61 typedef long long jk_pool_atom_t;
62 #elif defined(NETWARE)
63 typedef long long jk_pool_atom_t;
65 typedef long long jk_pool_atom_t;
67 typedef long long jk_pool_atom_t;
69 typedef void *jk_pool_atom_t;
71 typedef long long jk_pool_atom_t;
78 /* JK_ALIGN() is only to be used to align on a power of 2 boundary */
79 #define JK_ALIGN(size, boundary) \
80 (((size) + ((boundary) - 1)) & ~((boundary) - 1))
82 /** Default alignment */
84 #define JK_ALIGN_DEFAULT(size) JK_ALIGN(size, 16)
86 #define JK_ALIGN_DEFAULT(size) JK_ALIGN(size, 8)
90 * Pool size in number of pool atoms.
92 #define TINY_POOL_SIZE 256 /* Tiny 1/4K atom pool. */
93 #define SMALL_POOL_SIZE 512 /* Small 1/2K atom pool. */
94 #define BIG_POOL_SIZE 2*SMALL_POOL_SIZE /* Bigger 1K atom pool. */
95 #define HUGE_POOL_SIZE 2*BIG_POOL_SIZE /* Huge 2K atom pool. */
97 /** jk pool structure */
108 typedef struct jk_pool jk_pool_t;
110 void jk_open_pool(jk_pool_t *p, jk_pool_atom_t *buf, size_t size);
112 void jk_close_pool(jk_pool_t *p);
114 void jk_reset_pool(jk_pool_t *p);
116 void *jk_pool_alloc(jk_pool_t *p, size_t sz);
118 void *jk_pool_realloc(jk_pool_t *p,
119 size_t sz, const void *old, size_t old_sz);
121 void *jk_pool_strdup(jk_pool_t *p, const char *s);
125 #endif /* __cplusplus */
126 #endif /* _JK_POOL_H */