提交 3ae1d7bd 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

placement new operators

上级 62934703
...@@ -136,6 +136,11 @@ extern void *__dso_handle; ...@@ -136,6 +136,11 @@ extern void *__dso_handle;
return kmalloc(sizeof(classname)); \ return kmalloc(sizeof(classname)); \
} \ } \
\ \
static void* operator new(unsigned long nbytes, classname *buf) { \
assert(nbytes == sizeof(classname)); \
return buf; \
} \
\
static void operator delete(void *p) { \ static void operator delete(void *p) { \
kmfree(p, sizeof(classname)); \ kmfree(p, sizeof(classname)); \
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论