projects
/
cdsspec-compiler.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1064d48
)
malloc: override 'new' and 'delete' globally
author
Brian Norris
<banorris@uci.edu>
Thu, 5 Apr 2012 02:41:46 +0000
(19:41 -0700)
committer
Brian Norris
<banorris@uci.edu>
Thu, 5 Apr 2012 17:05:30 +0000
(10:05 -0700)
Not sure if this is correct...
Q: do we also need to overload new[] and delete[]?
malloc.c
patch
|
blob
|
history
diff --git
a/malloc.c
b/malloc.c
index 196be4320abee7c1f6a66d46f8ee1ad104f45bcd..82fdd04c2f6319478547cac7c9a22c0f88dc512d 100644
(file)
--- a/
malloc.c
+++ b/
malloc.c
@@
-6,6
+6,7
@@
#endif
#include <dlfcn.h>
+#include <new>
static void * (*real_malloc)(size_t) = NULL;
static void (*real_free)(void *ptr) = NULL;
@@
-36,3
+37,13
@@
void myFree(void *ptr)
real_free(ptr);
}
+
+void * operator new(size_t size)
+{
+ return myMalloc(size);
+}
+
+void operator delete(void *p)
+{
+ myFree(p);
+}