~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_once.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

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