1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include "mysys_priv.h"
20
Malloc many pointers at the same time
21
Only ptr1 can be free'd, and doing this will free all
22
the memory allocated. ptr2, etc all point inside big allocated
28
ptr1, length1 Multiple arguments terminated by null ptr
34
void* my_multi_malloc(myf myFlags, ...)
37
char **ptr,*start,*res;
38
size_t tot_length,length;
39
DBUG_ENTER("my_multi_malloc");
41
va_start(args,myFlags);
43
while ((ptr=va_arg(args, char **)))
45
length=va_arg(args,uint);
46
tot_length+=ALIGN_SIZE(length);
50
if (!(start=(char *) my_malloc(tot_length,myFlags)))
51
DBUG_RETURN(0); /* purecov: inspected */
53
va_start(args,myFlags);
55
while ((ptr=va_arg(args, char **)))
58
length=va_arg(args,uint);
59
res+=ALIGN_SIZE(length);
62
DBUG_RETURN((void*) start);