mymemory: define SNAPSHOTALLOC appropriately
authorBrian Norris <banorris@uci.edu>
Wed, 3 Oct 2012 18:15:05 +0000 (11:15 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 3 Oct 2012 18:45:52 +0000 (11:45 -0700)
SNAPSHOTALLOC can be filled in with meaningful allocators, rather than
using the global default allocators.

mymemory.h

index c49984f..1d4c123 100644 (file)
  *     memory in the non-snapshotting heap. */
 #define MEMALLOC \
        void * operator new(size_t size) { \
-               return model_malloc(size);\
-       }\
+               return model_malloc(size); \
+       } \
        void operator delete(void *p, size_t size) { \
-               model_free( p ); \
-       }\
+               model_free(p); \
+       } \
        void * operator new[](size_t size) { \
-               return model_malloc(size);\
-       }\
-       void operator delete[](void *p, size_t size) {\
-               model_free(p);\
+               return model_malloc(size); \
+       } \
+       void operator delete[](void *p, size_t size) { \
+               model_free(p); \
        }
 
 /** SNAPSHOTALLOC declares the allocators for a class to allocate
  *     memory in the snapshotting heap. */
-#define SNAPSHOTALLOC
+#define SNAPSHOTALLOC \
+       void * operator new(size_t size) { \
+               return snapshot_malloc(size); \
+       } \
+       void operator delete(void *p, size_t size) { \
+               snapshot_free(p); \
+       } \
+       void * operator new[](size_t size) { \
+               return snapshot_malloc(size); \
+       } \
+       void operator delete[](void *p, size_t size) { \
+               snapshot_free(p); \
+       }
 
 void *model_malloc(size_t size);
 void *model_calloc(size_t count, size_t size);