From: Brian Norris Date: Fri, 7 Dec 2012 05:50:33 +0000 (-0800) Subject: mymemory: add placement new X-Git-Tag: oopsla2013~454 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9885ab0975d0b812219321ca14794d0f2ca3802c;p=model-checker.git mymemory: add placement new I will need to use the placement new operator, if I want to allocate an object with an allocator other than the one I established (SNAPSHOTALLOC vs. MODELALLOC). --- diff --git a/mymemory.h b/mymemory.h index 05b89be..794c4e5 100644 --- a/mymemory.h +++ b/mymemory.h @@ -23,6 +23,9 @@ } \ void operator delete[](void *p, size_t size) { \ model_free(p); \ + } \ + void * operator new(size_t size, void *p) { /* placement new */ \ + return p; \ } /** SNAPSHOTALLOC declares the allocators for a class to allocate @@ -39,6 +42,9 @@ } \ void operator delete[](void *p, size_t size) { \ snapshot_free(p); \ + } \ + void * operator new(size_t size, void *p) { /* placement new */ \ + return p; \ } void *model_malloc(size_t size);