3 * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_memory.h,v 1.5 2008/01/29 01:56:39 y-asaba Exp $
5 * pgpool: a language independent connection pool server for PostgreSQL
6 * written by Tatsuo Ishii
8 * Copyright (c) 2003-2008 PgPool Global Development Group
10 * Permission to use, copy, modify, and distribute this software and
11 * its documentation for any purpose and without fee is hereby
12 * granted, provided that the above copyright notice appear in all
13 * copies and that both that copyright notice and this permission
14 * notice appear in supporting documentation, and that the name of the
15 * author not be used in advertising or publicity pertaining to
16 * distribution of the software without specific, written prior
17 * permission. The author makes no representations about the
18 * suitability of this software for any purpose. It is provided "as
19 * is" without express or implied warranty.
21 * pool_memory.h: Memory pooling module for SQL parser.
30 #define PARSER_BLOCK_SIZE 8192
31 #define PREPARE_BLOCK_SIZE 1024
33 typedef struct POOL_BLOCK {
38 struct POOL_BLOCK *next;
43 struct POOL_CHUNK *next;
46 typedef struct POOL_CHUNK {
47 POOL_CHUNK_HEADER header;
55 POOL_BLOCK *largeblocks;
56 POOL_CHUNK *freelist[SLOT_NUM];
59 extern POOL_MEMORY_POOL *pool_memory;
61 extern void *pool_memory_alloc(POOL_MEMORY_POOL *pool, unsigned int size);
62 extern void pool_memory_free(POOL_MEMORY_POOL *pool, void *ptr);
63 extern void *pool_memory_realloc(POOL_MEMORY_POOL *pool, void *ptr, unsigned int size);
64 extern POOL_MEMORY_POOL *pool_memory_create(int blocksize);
65 extern void pool_memory_delete(POOL_MEMORY_POOL *pool_memory, int reuse);
66 extern char *pool_memory_strdup(POOL_MEMORY_POOL *pool_memory, const char *string);
67 extern void *pool_memory_alloc_zero(POOL_MEMORY_POOL *pool_memory, unsigned int size);
69 #define palloc(s) pool_memory_alloc(pool_memory, (s))
70 #define pfree(p) pool_memory_free(pool_memory, (p))
71 #define repalloc(p, s) pool_memory_realloc(pool_memory, (p), (s))
72 #define pstrdup(s) pool_memory_strdup(pool_memory, (s))
73 #define palloc0(s) pool_memory_alloc_zero(pool_memory, (s))
75 #endif /* POOL_MEMORY_H */