2011-02-25 11:41:12 +00:00
|
|
|
/*
|
2009-08-18 15:20:29 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-08-18 15:20:29 +00:00
|
|
|
*
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-25 11:41:12 +00:00
|
|
|
/** \file guardedalloc/cpp/mallocn.cpp
|
|
|
|
* \ingroup MEM
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-08-18 15:20:29 +00:00
|
|
|
#include <new>
|
|
|
|
#include "../MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
void* operator new (size_t size)
|
|
|
|
{
|
2010-10-08 20:40:42 +00:00
|
|
|
return MEM_mallocN(size, "C++/anonymous");
|
2009-08-18 15:20:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* not default but can be used when needing to set a string */
|
|
|
|
void* operator new (size_t size, const char *str)
|
|
|
|
{
|
|
|
|
return MEM_mallocN(size, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator delete (void *p)
|
|
|
|
{
|
2012-05-04 16:38:11 +00:00
|
|
|
/* delete NULL is valid in c++ */
|
|
|
|
if(p)
|
|
|
|
MEM_freeN(p);
|
2009-08-18 15:20:29 +00:00
|
|
|
}
|