-/** Snapshotting free implementation for user programs. */
-void free( void * ptr ){
- if( DontFree( ptr ) ) return;
- mspace_free( mySpace, ptr );
+/**
+ * @brief Snapshotting malloc implementation for user programs
+ *
+ * Do NOT call this function from a model-checker context. Doing so may disrupt
+ * the allocation patterns of a user thread.
+ */
+void *malloc(size_t size)
+{
+ if (user_snapshot_space) {
+ /* Only perform user allocations from user context */
+ ASSERT(!model || thread_current());
+ return user_malloc(size);
+ } else
+ return HandleEarlyAllocationRequest(size);