~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_once.c

Removed/replaced DBUG symbols and standardized TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "mysys_priv.h"
19
19
#include "my_static.h"
20
20
#include "mysys_err.h"
21
 
#include <mystrings/m_string.h>
 
21
#include <m_string.h>
22
22
 
23
23
/*
24
24
  Alloc for things we don't nead to free
27
27
    my_once_alloc()
28
28
      Size
29
29
      MyFlags
 
30
 
 
31
  NOTES
 
32
    No DBUG_ENTER... here to get smaller dbug-startup 
30
33
*/
31
34
 
32
35
void* my_once_alloc(size_t Size, myf MyFlags)
33
36
{
34
37
  size_t get_size, max_left;
35
 
  unsigned char* point;
 
38
  uchar* point;
36
39
  register USED_MEM *next;
37
40
  register USED_MEM **prev;
38
41
 
56
59
      my_errno=errno;
57
60
      if (MyFlags & (MY_FAE+MY_WME))
58
61
        my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),get_size);
59
 
      return((unsigned char*) 0);
 
62
      return((uchar*) 0);
60
63
    }
 
64
    DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size));
61
65
    next->next= 0;
62
66
    next->size= get_size;
63
67
    next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
64
68
    *prev=next;
65
69
  }
66
 
  point= (unsigned char*) ((char*) next+ (next->size-next->left));
 
70
  point= (uchar*) ((char*) next+ (next->size-next->left));
67
71
  next->left-= Size;
68
72
 
69
73
  if (MyFlags & MY_ZEROFILL)
70
 
    memset(point, 0, Size);
 
74
    bzero(point, Size);
71
75
  return((void*) point);
72
76
} /* my_once_alloc */
73
77
 
75
79
char *my_once_strdup(const char *src,myf myflags)
76
80
{
77
81
  size_t len= strlen(src)+1;
78
 
  unsigned char *dst= my_once_alloc(len, myflags);
 
82
  uchar *dst= my_once_alloc(len, myflags);
79
83
  if (dst)
80
84
    memcpy(dst, src, len);
81
85
  return (char*) dst;
84
88
 
85
89
void *my_once_memdup(const void *src, size_t len, myf myflags)
86
90
{
87
 
  unsigned char *dst= my_once_alloc(len, myflags);
 
91
  uchar *dst= my_once_alloc(len, myflags);
88
92
  if (dst)
89
93
    memcpy(dst, src, len);
90
94
  return dst;
101
105
void my_once_free(void)
102
106
{
103
107
  register USED_MEM *next,*old;
 
108
  DBUG_ENTER("my_once_free");
104
109
 
105
110
  for (next=my_once_root_block ; next ; )
106
111
  {
107
112
    old=next; next= next->next ;
108
 
    free((unsigned char*) old);
 
113
    free((uchar*) old);
109
114
  }
110
115
  my_once_root_block=0;
111
116
 
112
 
  return;
 
117
  DBUG_VOID_RETURN;
113
118
} /* my_once_free */