1
by brian
clean slate |
1 |
/* Copyright (C) 2000 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
16 |
/*
|
1
by brian
clean slate |
17 |
Data structures for mysys/my_alloc.c (root memory allocator)
|
18 |
*/
|
|
19 |
||
1122.2.10
by Monty Taylor
Fixed all of the include guards. |
20 |
#ifndef MYSYS_MY_ALLOC_H
|
21 |
#define MYSYS_MY_ALLOC_H
|
|
1
by brian
clean slate |
22 |
|
575.1.6
by Monty Taylor
Cleaned up some headers for PCH. |
23 |
#include <stddef.h> |
24 |
#include <drizzled/definitions.h> |
|
25 |
||
492.1.3
by Monty Taylor
Merged from Lee. |
26 |
#if defined(__cplusplus)
|
27 |
extern "C" { |
|
28 |
#endif
|
|
29 |
||
1
by brian
clean slate |
30 |
#define ALLOC_MAX_BLOCK_TO_DROP 4096
|
31 |
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
|
|
32 |
||
33 |
typedef struct st_used_mem |
|
34 |
{ /* struct for once_alloc (block) */ |
|
35 |
struct st_used_mem *next; /* Next block in use */ |
|
1126.13.6
by Joe Daly
change struct type to size_t as its dealing with memory allocation, this should be unsigned int and will eliminate many warnings |
36 |
size_t left; /* memory left in block */ |
37 |
size_t size; /* size of block */ |
|
1
by brian
clean slate |
38 |
} USED_MEM; |
39 |
||
40 |
||
41 |
typedef struct st_mem_root |
|
42 |
{
|
|
43 |
USED_MEM *free; /* blocks with free memory in it */ |
|
44 |
USED_MEM *used; /* blocks almost without free memory */ |
|
45 |
USED_MEM *pre_alloc; /* preallocated block */ |
|
46 |
/* if block have less memory it will be put in 'used' list */
|
|
47 |
size_t min_malloc; |
|
48 |
size_t block_size; /* initial block size */ |
|
49 |
unsigned int block_num; /* allocated blocks counter */ |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
50 |
/*
|
51 |
first free block in queue test counter (if it exceed
|
|
1
by brian
clean slate |
52 |
MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
|
53 |
*/
|
|
54 |
unsigned int first_block_usage; |
|
55 |
||
56 |
void (*error_handler)(void); |
|
57 |
} MEM_ROOT; |
|
492.1.1
by Monty Taylor
Moved MEM_ROOT functions into my_alloc.h. |
58 |
|
59 |
void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, |
|
60 |
size_t pre_alloc_size); |
|
61 |
void *alloc_root(MEM_ROOT *mem_root, size_t Size); |
|
62 |
void *multi_alloc_root(MEM_ROOT *mem_root, ...); |
|
63 |
void free_root(MEM_ROOT *root, myf MyFLAGS); |
|
64 |
void set_prealloc_root(MEM_ROOT *root, char *ptr); |
|
65 |
void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, |
|
66 |
size_t prealloc_size); |
|
67 |
char *strdup_root(MEM_ROOT *root,const char *str); |
|
68 |
char *strmake_root(MEM_ROOT *root,const char *str,size_t len); |
|
69 |
void *memdup_root(MEM_ROOT *root,const void *str, size_t len); |
|
70 |
||
492.1.3
by Monty Taylor
Merged from Lee. |
71 |
#if defined(__cplusplus)
|
72 |
}
|
|
73 |
#endif
|
|
1122.2.10
by Monty Taylor
Fixed all of the include guards. |
74 |
#endif /* MYSYS_MY_ALLOC_H */ |