#include "mymemory.h"
#include "snapshot.h"
#include "common.h"
+#include "threads-model.h"
+#include "model.h"
#define REQUESTS_BEFORE_ALLOC 1024
*/
void *malloc(size_t size)
{
- if (user_snapshot_space)
+ if (user_snapshot_space) {
+ /* Only perform user allocations from user context */
+ ASSERT(!model || thread_current());
return user_malloc(size);
- else
+ } else
return HandleEarlyAllocationRequest(size);
}
{
free(p);
}
-#endif /* USE_MPROTECT_SNAPSHOT */
+
+#else /* !USE_MPROTECT_SNAPSHOT */
+
+/** @brief Snapshotting allocation function for use by the Thread class only */
+void * Thread_malloc(size_t size)
+{
+ return malloc(size);
+}
+
+/** @brief Snapshotting free function for use by the Thread class only */
+void Thread_free(void *ptr)
+{
+ free(ptr);
+}
+
+#endif /* !USE_MPROTECT_SNAPSHOT */