+
+
+/** This global references the mspace for the snapshotting heap */
+mspace mySpace = NULL;
+
+/** This global references the unaligned memory address that was malloced for the snapshotting heap */
+void * basemySpace = NULL;
+
+/** Bootstrap allocation. Problem is that the dynamic linker calls
+ * require calloc to work and calloc requires the dynamic linker to
+ * work. */
+
+#define BOOTSTRAPBYTES 4096
+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)) {
+ printf("OUT OF BOOTSTRAP MEMORY\n");
+ exit(EXIT_FAILURE);
+ }
+
+ void * pointer= (void *) & bootstrapmemory[offset];
+ offset+=sz;
+ return pointer;
+}
+
+/** Check whether this is bootstrapped memory that we should not
+ free. */
+
+bool DontFree( void * ptr ){
+ return (ptr>=(&bootstrapmemory[0])&&ptr<(&bootstrapmemory[BOOTSTRAPBYTES]));
+}
+
+/** Snapshotting malloc implementation for user programs. */