~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_alloc.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 21:21:21 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717212121-5qx4zm1fbqkz8ss0
Phase 6 - Remove DBUG from mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
47
47
                     size_t pre_alloc_size __attribute__((unused)))
48
48
{
49
 
  DBUG_ENTER("init_alloc_root");
50
 
  DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
51
 
 
52
49
  mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
53
50
  mem_root->min_malloc= 32;
54
51
  mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
69
66
    }
70
67
  }
71
68
#endif
72
 
  DBUG_VOID_RETURN;
 
69
  return;
73
70
}
74
71
 
75
72
 
93
90
void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
94
91
                         size_t pre_alloc_size __attribute__((unused)))
95
92
{
96
 
  DBUG_ASSERT(alloc_root_inited(mem_root));
 
93
  assert(alloc_root_inited(mem_root));
97
94
 
98
95
  mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
99
96
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
149
146
{
150
147
#if defined(HAVE_purify) && defined(EXTRA_DEBUG)
151
148
  register USED_MEM *next;
152
 
  DBUG_ENTER("alloc_root");
153
 
  DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
154
149
 
155
 
  DBUG_ASSERT(alloc_root_inited(mem_root));
 
150
  assert(alloc_root_inited(mem_root));
156
151
 
157
152
  length+=ALIGN_SIZE(sizeof(USED_MEM));
158
153
  if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME | ME_FATALERROR))))
159
154
  {
160
155
    if (mem_root->error_handler)
161
156
      (*mem_root->error_handler)();
162
 
    DBUG_RETURN((uchar*) 0);                    /* purecov: inspected */
 
157
    return((uchar*) 0);                 /* purecov: inspected */
163
158
  }
164
159
  next->next= mem_root->used;
165
160
  next->size= length;
166
161
  mem_root->used= next;
167
 
  DBUG_PRINT("exit",("ptr: 0x%lx", (long) (((char*) next)+
168
 
                                           ALIGN_SIZE(sizeof(USED_MEM)))));
169
 
  DBUG_RETURN((uchar*) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
 
162
  return((uchar*) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
170
163
#else
171
164
  size_t get_size, block_size;
172
165
  uchar* point;
173
166
  register USED_MEM *next= 0;
174
167
  register USED_MEM **prev;
175
 
  DBUG_ENTER("alloc_root");
176
 
  DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
177
 
  DBUG_ASSERT(alloc_root_inited(mem_root));
 
168
  assert(alloc_root_inited(mem_root));
178
169
 
179
170
  length= ALIGN_SIZE(length);
180
171
  if ((*(prev= &mem_root->free)) != NULL)
202
193
    {
203
194
      if (mem_root->error_handler)
204
195
        (*mem_root->error_handler)();
205
 
      DBUG_RETURN((void*) 0);                      /* purecov: inspected */
 
196
      return((void*) 0);                      /* purecov: inspected */
206
197
    }
207
198
    mem_root->block_num++;
208
199
    next->next= *prev;
220
211
    mem_root->used= next;
221
212
    mem_root->first_block_usage= 0;
222
213
  }
223
 
  DBUG_PRINT("exit",("ptr: 0x%lx", (ulong) point));
224
 
  DBUG_RETURN((void*) point);
 
214
  return((void*) point);
225
215
#endif
226
216
}
227
217
 
250
240
  va_list args;
251
241
  char **ptr, *start, *res;
252
242
  size_t tot_length, length;
253
 
  DBUG_ENTER("multi_alloc_root");
254
243
 
255
244
  va_start(args, root);
256
245
  tot_length= 0;
262
251
  va_end(args);
263
252
 
264
253
  if (!(start= (char*) alloc_root(root, tot_length)))
265
 
    DBUG_RETURN(0);                            /* purecov: inspected */
 
254
    return(0);                            /* purecov: inspected */
266
255
 
267
256
  va_start(args, root);
268
257
  res= start;
273
262
    res+= ALIGN_SIZE(length);
274
263
  }
275
264
  va_end(args);
276
 
  DBUG_RETURN((void*) start);
 
265
  return((void*) start);
277
266
}
278
267
 
279
268
#define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left)
331
320
void free_root(MEM_ROOT *root, myf MyFlags)
332
321
{
333
322
  register USED_MEM *next,*old;
334
 
  DBUG_ENTER("free_root");
335
 
  DBUG_PRINT("enter",("root: 0x%lx  flags: %u", (long) root, (uint) MyFlags));
336
323
 
337
324
  if (MyFlags & MY_MARK_BLOCKS_FREE)
338
325
  {
339
326
    mark_blocks_free(root);
340
 
    DBUG_VOID_RETURN;
 
327
    return;
341
328
  }
342
329
  if (!(MyFlags & MY_KEEP_PREALLOC))
343
330
    root->pre_alloc=0;
364
351
  }
365
352
  root->block_num= 4;
366
353
  root->first_block_usage= 0;
367
 
  DBUG_VOID_RETURN;
 
354
  return;
368
355
}
369
356
 
370
357
/*