~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_alloc.h

Merge of Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
/* 
 
16
/*
17
17
   Data structures for mysys/my_alloc.c (root memory allocator)
18
18
*/
19
19
 
20
20
#ifndef _my_alloc_h
21
21
#define _my_alloc_h
22
22
 
 
23
#include <stddef.h>
 
24
#include <drizzled/definitions.h>
 
25
 
 
26
#if defined(__cplusplus)
 
27
extern "C" {
 
28
#endif
 
29
 
23
30
#define ALLOC_MAX_BLOCK_TO_DROP                 4096
24
31
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP       10
25
32
 
40
47
  size_t min_malloc;
41
48
  size_t block_size;               /* initial block size */
42
49
  unsigned int block_num;          /* allocated blocks counter */
43
 
  /* 
44
 
     first free block in queue test counter (if it exceed 
 
50
  /*
 
51
     first free block in queue test counter (if it exceed
45
52
     MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
46
53
  */
47
54
  unsigned int first_block_usage;
48
55
 
49
56
  void (*error_handler)(void);
50
57
} MEM_ROOT;
 
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
 
 
71
#if defined(__cplusplus)
 
72
}
 
73
#endif
51
74
#endif