~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/memory/root.h

  • Committer: Monty Taylor
  • Date: 2009-12-25 08:50:15 UTC
  • mto: This revision was merged to the branch mainline in revision 1255.
  • Revision ID: mordred@inaugust.com-20091225085015-83sux5qsvy312gew
MEM_ROOT == memory::Root

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
static const size_t ROOT_MIN_BLOCK_SIZE= (MALLOC_OVERHEAD + sizeof(internal::UsedMemory) + 8);
51
51
 
52
 
}
53
 
}
54
 
 
55
 
 
56
 
 
57
 
typedef struct st_mem_root
 
52
 
 
53
 
 
54
class Root
58
55
{
 
56
public:
59
57
  /* blocks with free memory in it */
60
 
  drizzled::memory::internal::UsedMemory *free;
 
58
  internal::UsedMemory *free;
61
59
 
62
60
  /* blocks almost without free memory */
63
 
  drizzled::memory::internal::UsedMemory *used;
 
61
  internal::UsedMemory *used;
64
62
 
65
63
  /* preallocated block */
66
 
  drizzled::memory::internal::UsedMemory *pre_alloc;
 
64
  internal::UsedMemory *pre_alloc;
67
65
 
68
66
  /* if block have less memory it will be put in 'used' list */
69
67
  size_t min_malloc;
76
74
  unsigned int first_block_usage;
77
75
 
78
76
  void (*error_handler)(void);
79
 
} MEM_ROOT;
 
77
};
80
78
 
81
 
inline static bool alloc_root_inited(MEM_ROOT *root)
 
79
inline static bool alloc_root_inited(Root *root)
82
80
{
83
81
  return root->min_malloc != 0;
84
82
}
85
83
 
86
 
void init_alloc_root(MEM_ROOT *mem_root,
87
 
                     size_t block_size= drizzled::memory::ROOT_MIN_BLOCK_SIZE);
88
 
void *alloc_root(MEM_ROOT *mem_root, size_t Size);
89
 
void *multi_alloc_root(MEM_ROOT *mem_root, ...);
90
 
void free_root(MEM_ROOT *root, myf MyFLAGS);
91
 
void set_prealloc_root(MEM_ROOT *root, char *ptr);
92
 
void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
 
84
void init_alloc_root(Root *mem_root,
 
85
                     size_t block_size= ROOT_MIN_BLOCK_SIZE);
 
86
void *alloc_root(Root *mem_root, size_t Size);
 
87
void *multi_alloc_root(Root *mem_root, ...);
 
88
void free_root(Root *root, myf MyFLAGS);
 
89
void set_prealloc_root(Root *root, char *ptr);
 
90
void reset_root_defaults(Root *mem_root, size_t block_size,
93
91
                         size_t prealloc_size);
94
 
char *strdup_root(MEM_ROOT *root,const char *str);
95
 
char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
96
 
void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
 
92
char *strdup_root(Root *root,const char *str);
 
93
char *strmake_root(Root *root,const char *str,size_t len);
 
94
void *memdup_root(Root *root,const void *str, size_t len);
 
95
 
 
96
}
 
97
}
97
98
 
98
99
#if defined(__cplusplus)
99
100
}