13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include "mysys_priv.h"
18
17
#include <stdarg.h>
22
#include "drizzled/memory/multi_malloc.h"
23
#include "drizzled/definitions.h"
30
20
Malloc many pointers at the same time
31
21
Only ptr1 can be free'd, and doing this will free all
37
zerofill Whether or not to fill with 0
38
28
ptr1, length1 Multiple arguments terminated by null ptr
44
void* multi_malloc(bool zerofill, ...)
34
void* my_multi_malloc(myf myFlags, ...)
37
char **ptr,*start,*res;
49
38
size_t tot_length,length;
51
va_start(args, zerofill);
40
va_start(args,myFlags);
53
while ((ptr=va_arg(args, void **)))
42
while ((ptr=va_arg(args, char **)))
56
* This must be unsigned int, not size_t.
57
* Otherwise, everything breaks.
59
length=va_arg(args, unsigned int);
44
length=va_arg(args,uint);
60
45
tot_length+=ALIGN_SIZE(length);
64
if (!(start= malloc(tot_length)))
67
memset(start, 0, tot_length);
49
if (!(start=(char *) my_malloc(tot_length,myFlags)))
50
return(0); /* purecov: inspected */
69
va_start(args, zerofill);
70
res= static_cast<char *>(start);
71
while ((ptr=va_arg(args, void **)))
52
va_start(args,myFlags);
54
while ((ptr=va_arg(args, char **)))
74
length=va_arg(args,unsigned int);
75
res+= ALIGN_SIZE(length);
57
length=va_arg(args,uint);
58
res+=ALIGN_SIZE(length);
61
return((void*) start);
81
} /* namespace memory */
82
} /* namespace drizzled */