]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - parser/pool_memory.h
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / parser / pool_memory.h
1 /* -*-pgsql-c-*- */
2 /*
3  * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_memory.h,v 1.5 2008/01/29 01:56:39 y-asaba Exp $
4  *
5  * pgpool: a language independent connection pool server for PostgreSQL 
6  * written by Tatsuo Ishii
7  *
8  * Copyright (c) 2003-2008      PgPool Global Development Group
9  *
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.
20  *
21  * pool_memory.h: Memory pooling module for SQL parser.
22  *
23  */
24
25 #ifndef POOL_MEMORY_H
26 #define POOL_MEMORY_H
27
28 #define SLOT_NUM 11
29
30 #define PARSER_BLOCK_SIZE 8192
31 #define PREPARE_BLOCK_SIZE 1024
32
33 typedef struct POOL_BLOCK {
34         int size;
35         int allocsize;
36         void *block;
37         void *freepoint;
38         struct POOL_BLOCK *next;
39 } POOL_BLOCK;
40
41 typedef union {
42         unsigned int size;
43         struct POOL_CHUNK *next;
44 } POOL_CHUNK_HEADER;
45
46 typedef struct POOL_CHUNK {
47         POOL_CHUNK_HEADER header;
48         char data[1];
49 } POOL_CHUNK;
50
51 typedef struct {
52         int size;
53         int blocksize;
54         POOL_BLOCK *blocks;
55         POOL_BLOCK *largeblocks;
56         POOL_CHUNK *freelist[SLOT_NUM];
57 } POOL_MEMORY_POOL;
58
59 extern POOL_MEMORY_POOL *pool_memory;
60
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);
68
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))
74
75 #endif /* POOL_MEMORY_H */