-void AddUserHeapToSnapshot(){
- static bool alreadySnapshotted = false;
- if( alreadySnapshotted ) return;
- addMemoryRegionToSnapShot( mySpace, MSPACE_SIZE / PAGESIZE );
+/** @brief Snapshotting free, for use by model-checker (not user progs) */
+void snapshot_free(void *ptr)
+{
+ mspace_free(model_snapshot_space, ptr);
+}
+
+/** Non-snapshotting free for our use. */
+void model_free(void *ptr)
+{
+ mspace_free(sStaticSpace, ptr);
+}
+
+/** Bootstrap allocation. Problem is that the dynamic linker calls require
+ * calloc to work and calloc requires the dynamic linker to work. */
+
+#define BOOTSTRAPBYTES 131072
+char bootstrapmemory[BOOTSTRAPBYTES];
+size_t offset = 0;
+
+void * HandleEarlyAllocationRequest(size_t sz)
+{
+ /* Align to 8 byte boundary */
+ sz = (sz + 7) & ~7;
+
+ if (sz > (BOOTSTRAPBYTES-offset)) {
+ model_print("OUT OF BOOTSTRAP MEMORY. Increase the size of BOOTSTRAPBYTES in mymemory.cc\n");
+ exit(EXIT_FAILURE);
+ }
+
+ void *pointer = (void *)&bootstrapmemory[offset];
+ offset += sz;
+ return pointer;