~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_realloc.c

MergingĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
void* my_realloc(void* oldpoint, size_t size, myf my_flags)
32
32
{
33
33
  void *point;
 
34
  DBUG_ENTER("my_realloc");
 
35
  DBUG_PRINT("my",("ptr: 0x%lx  size: %lu  my_flags: %d", (long) oldpoint,
 
36
                   (ulong) size, my_flags));
34
37
 
35
 
  assert(size > 0);
 
38
  DBUG_ASSERT(size > 0);
36
39
  if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
37
 
    return(my_malloc(size,my_flags));
 
40
    DBUG_RETURN(my_malloc(size,my_flags));
38
41
#ifdef USE_HALLOC
39
42
  if (!(point = malloc(size)))
40
43
  {
41
44
    if (my_flags & MY_FREE_ON_ERROR)
42
 
      free(oldpoint);
 
45
      my_free(oldpoint,my_flags);
43
46
    if (my_flags & MY_HOLD_ON_ERROR)
44
 
      return(oldpoint);
 
47
      DBUG_RETURN(oldpoint);
45
48
    my_errno=errno;
46
49
    if (my_flags & MY_FAE+MY_WME)
47
50
      my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
52
55
    free(oldpoint);
53
56
  }
54
57
#else
55
 
  if ((point= (unsigned char*) realloc(oldpoint,size)) == NULL)
 
58
  if ((point= (uchar*) realloc(oldpoint,size)) == NULL)
56
59
  {
57
60
    if (my_flags & MY_FREE_ON_ERROR)
58
 
      free(oldpoint);
 
61
      my_free(oldpoint, my_flags);
59
62
    if (my_flags & MY_HOLD_ON_ERROR)
60
 
      return(oldpoint);
 
63
      DBUG_RETURN(oldpoint);
61
64
    my_errno=errno;
62
65
    if (my_flags & (MY_FAE+MY_WME))
63
66
      my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
64
67
  }
65
68
#endif
66
 
  return(point);
 
69
  DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
 
70
  DBUG_RETURN(point);
67
71
} /* my_realloc */