File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1- LD_FLAGS+ = -L$(V8_PATH ) /out.gn/x64.release.sample/obj/ -lv8_monolith -lpthread -lstdc++fs
1+
2+ # Note: -Bsymbolic is necessary to ensure new/delete goes through the overrides in new.cpp and is tracked
3+ LD_FLAGS+ = -L$(V8_PATH ) /out.gn/x64.release.sample/obj/ -lv8_monolith -lpthread -lstdc++fs -static-libstdc++ -Wl,-Bsymbolic
24CXX_FLAGS+ = -std=c++17 -fvisibility=hidden -fPIC -O2 -g -isystem $(V8_PATH ) /include -DV8_COMPRESS_POINTERS
35
4- MODULE_OBJS = js.o module.o sha256.o
6+ MODULE_OBJS = js.o module.o sha256.o new.o
57
68modjs.so : $(MODULE_OBJS ) | check-env
79 $(CXX ) -shared -o $@ $^ $(LD_FLAGS )
Original file line number Diff line number Diff line change 1+ #include < cstddef> // std::size_t
2+ #include < new>
3+
4+ extern void *(*RedisModule_Alloc)(size_t bytes);
5+ extern void (*RedisModule_Free)(void *ptr);
6+ extern void *(*RedisModule_Calloc)(size_t nmemb, size_t size);
7+
8+ void *operator new (size_t size)
9+ {
10+ return RedisModule_Alloc (size);
11+ }
12+
13+ void * operator new (std::size_t size, const std::nothrow_t &)
14+ {
15+ return RedisModule_Alloc (size);
16+ }
17+
18+ void operator delete (void * p) noexcept
19+ {
20+ RedisModule_Free (p);
21+ }
22+
23+ void operator delete (void *p, std::size_t ) noexcept
24+ {
25+ RedisModule_Free (p);
26+ }
You can’t perform that action at this time.
0 commit comments