Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2009-08-26 14:27:04 +0400
committerJoseph Eagar <joeedh@gmail.com>2009-08-26 14:27:04 +0400
commitde7f08cc41c7087ecde096c89ee58f43ccb1cf91 (patch)
tree401ab2a2a7429c2caa63c3135341958155a86935 /intern/guardedalloc
parenta34ffefa0025d144826cd1bf7a136af743847f1b (diff)
parentd893b0f9ff5fc21277b9c24568e224961537c23c (diff)
merge with 2.5 at r22793
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/BLO_sys_types.h2
-rw-r--r--intern/guardedalloc/CMakeLists.txt7
-rw-r--r--intern/guardedalloc/cpp/mallocn.cpp41
3 files changed, 48 insertions, 2 deletions
diff --git a/intern/guardedalloc/BLO_sys_types.h b/intern/guardedalloc/BLO_sys_types.h
index 5ed3117c890..e3c64f9746a 100644
--- a/intern/guardedalloc/BLO_sys_types.h
+++ b/intern/guardedalloc/BLO_sys_types.h
@@ -82,7 +82,7 @@ typedef unsigned long uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__NetBSD__)
/* Linux-i386, Linux-Alpha, Linux-ppc */
#include <stdint.h>
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index af64fb99d58..b29837fac7d 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -29,4 +29,9 @@ SET(INC .)
FILE(GLOB SRC intern/*.c)
BLENDERLIB(bf_guardedalloc "${SRC}" "${INC}")
-#, libtype=['intern', 'player'], priority = [10, 175] )
+
+# Override C++ alloc optional
+IF(WITH_CXX_GUARDEDALLOC)
+ FILE(GLOB SRC cpp/*.cpp)
+ BLENDERLIB(bf_guardedalloc_cpp "${SRC}" "${INC}")
+ENDIF(WITH_CXX_GUARDEDALLOC)
diff --git a/intern/guardedalloc/cpp/mallocn.cpp b/intern/guardedalloc/cpp/mallocn.cpp
new file mode 100644
index 00000000000..0ee22e734b9
--- /dev/null
+++ b/intern/guardedalloc/cpp/mallocn.cpp
@@ -0,0 +1,41 @@
+/**
+ * $Id$
+ * ***** 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <new>
+#include "../MEM_guardedalloc.h"
+
+void* operator new (size_t size)
+{
+ return MEM_mallocN(size, "c++/anonymous");
+}
+
+/* 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)
+{
+ MEM_freeN(p);
+}