~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/memory/root.cc

  • Committer: Mark Atwood
  • Date: 2011-06-24 02:13:02 UTC
  • mfrom: (2318.6.56 rf)
  • Revision ID: me@mark.atwood.name-20110624021302-y9oiksid220xan9s
mergeĀ lp:~olafvdspek/drizzle/refactor14

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 * chunk for memory allocation and pre-allocates first block if specified.
46
46
 * Altough error can happen during execution of this function if
47
47
 * pre_alloc_size is non-0 it won't be reported. Instead it will be
48
 
 * reported as error in first alloc_root() on this memory root.
 
48
 * reported as error in first alloc() on this memory root.
49
49
 *
50
50
 * @param  mem_root       memory root to initialize
51
51
 * @param  block_size     size of chunks (blocks) used for memory allocation
137
137
 * @todo Would this be more suitable as a member function on the
138
138
 * Root class?
139
139
 */
140
 
void* Root::alloc(size_t length)
 
140
unsigned char* Root::alloc(size_t length)
141
141
{
142
142
  internal::UsedMemory *next= NULL;
143
143
  assert(alloc_root_inited());
209
209
 * A pointer to the beginning of the allocated memory block in case of 
210
210
 * success or NULL if out of memory
211
211
 */
212
 
void* Root::multi_alloc_root(int unused, ...)
 
212
void* Root::multi_alloc(int unused, ...)
213
213
{
214
214
  va_list args;
215
215
  char* *ptr, *start, *res;
225
225
  }
226
226
  va_end(args);
227
227
 
228
 
  if (!(start= (char*) this->alloc_root(tot_length)))
229
 
    return(0);
 
228
  start= (char*) this->alloc(tot_length);
230
229
 
231
230
  va_start(args, unused);
232
231
  res= start;
344
343
 */
345
344
char* Root::strmake(const char* str, size_t len)
346
345
{
347
 
  char* pos= (char*)alloc_root(len + 1);
 
346
  char* pos= (char*)alloc(len + 1);
348
347
  memcpy(pos, str, len);
349
348
  pos[len]= 0;
350
349
  return pos;
371
370
 */
372
371
void* Root::memdup(const void* str, size_t len)
373
372
{
374
 
  void* pos= this->alloc_root(len);
 
373
  void* pos= alloc(len);
375
374
  memcpy(pos, str, len);
376
375
  return pos;
377
376
}