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"
17
#include "mysys_err.h"
20
/* My memory re allocator */
23
@brief wrapper around realloc()
25
@param oldpoint pointer to currently allocated area
26
@param size new size requested, must be >0
29
@note if size==0 realloc() may return NULL; my_realloc() treats this as an
30
error which is not the intention of realloc()
32
void* my_realloc(void* oldpoint, size_t size, myf my_flags)
37
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
38
return(my_malloc(size,my_flags));
40
if (!(point = malloc(size)))
42
if (my_flags & MY_FREE_ON_ERROR)
44
if (my_flags & MY_HOLD_ON_ERROR)
47
if (my_flags & MY_FAE+MY_WME)
48
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
52
memcpy(point,oldpoint,size);
56
if ((point= (unsigned char*) realloc(oldpoint,size)) == NULL)
58
if (my_flags & MY_FREE_ON_ERROR)
60
if (my_flags & MY_HOLD_ON_ERROR)
63
if (my_flags & (MY_FAE+MY_WME))
64
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);