Permalink
Browse files

build: link against bundled jemalloc

  • Loading branch information...
1 parent 6bccf79 commit 6b04ed0aac29f4bbb4382bb57448cc9f33016a19 @bnoordhuis committed Nov 23, 2011
Showing with 25 additions and 0 deletions.
  1. +1 −0 node.gyp
  2. +24 −0 src/node.h
View
@@ -178,6 +178,7 @@
[ 'OS=="linux"', {
'sources': [ 'src/platform_linux.cc' ],
'libraries': [
+ '/home/bnoordhuis/src/nodejs/node/deps/jemalloc/lib/libjemalloc.a',
'-ldl',
'-lutil' # needed for openpty
],
View
@@ -22,6 +22,30 @@
#ifndef SRC_NODE_H_
#define SRC_NODE_H_
+#if 1
+# include <stddef.h>
+extern "C" {
+void *jemalloc_malloc(size_t size);
+void *jemalloc_calloc(size_t number, size_t size);
+void *jemalloc_realloc(void *ptr, size_t size);
+void jemalloc_free(void *ptr);
+}
+
+inline void* operator new(size_t size)
+{
+ return jemalloc_malloc(size);
+}
+inline void operator delete(void* ptr, size_t size)
+{
+ jemalloc_free(ptr);
+}
+
+# define malloc(size) jemalloc_malloc(size)
+# define calloc(nmemb, size) jemalloc_calloc(nmemb, size)
+# define realloc(ptr, size) jemalloc_realloc(ptr, size)
+# define free(ptr) jemalloc_free(ptr)
+#endif
+
#ifdef _WIN32
# ifndef BUILDING_NODE_EXTENSION
# define NODE_EXTERN __declspec(dllexport)

0 comments on commit 6b04ed0

Please sign in to comment.