-#define MEMALLOC void *operator new( size_t size ){ \
- return MYMALLOC( size );\
- }\
- void operator delete( void *p, size_t size ){ \
- MYFREE( p ); \
- }\
- void *operator new[]( size_t size ){ \
- return MYMALLOC( size );\
- }\
- void operator delete[]( void *p, size_t size ){\
- MYFREE( p );\
- }
-
-
-void *MYMALLOC(size_t size);
-void MYFREE(void *ptr);
-void AddUserHeapToSnapshot();
-/*
-The following code example is taken from the book
-The C++ Standard Library - A Tutorial and Reference
-by Nicolai M. Josuttis, Addison-Wesley, 1999
-© Copyright Nicolai M. Josuttis 1999
-Permission to copy, use, modify, sell and distribute this software
-is granted provided this copyright notice appears in all copies.
-This software is provided "as is" without express or implied
-warranty, and with no claim as to its suitability for any purpose.
-*/
+
+/** MEMALLOC declares the allocators for a class to allocate
+ * memory in the non-snapshotting heap. */
+#define MEMALLOC \
+ void * operator new(size_t size) { \
+ return model_malloc(size); \
+ } \
+ void operator delete(void *p, size_t size) { \
+ model_free(p); \
+ } \
+ void * operator new[](size_t size) { \
+ 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 \
+ 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);
+void model_free(void *ptr);
+
+void * snapshot_malloc(size_t size);
+void * snapshot_calloc(size_t count, size_t size);
+void snapshot_free(void *ptr);
+
+void system_free( void * ptr );
+void *system_malloc( size_t size );
+
+/** @brief Provides a non-snapshotting allocator for use in STL classes.
+ *
+ * The code was adapted from a code example from the book The C++
+ * Standard Library - A Tutorial and Reference by Nicolai M. Josuttis,
+ * Addison-Wesley, 1999 © Copyright Nicolai M. Josuttis 1999
+ * Permission to copy, use, modify, sell and distribute this software
+ * is granted provided this copyright notice appears in all copies.
+ * This software is provided "as is" without express or implied
+ * warranty, and with no claim as to its suitability for any purpose.
+ */