|
@@ -50,24 +50,6 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
size_t min_split_size;
|
|
|
#endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */
|
|
|
|
|
|
-#ifndef WITH_MEMORY_SPACE_AWARENESS
|
|
|
- int heap_id;
|
|
|
-
|
|
|
- /* Go to the system allocator if none was given */
|
|
|
- if(allocator == NULL) {
|
|
|
- allocator = &systemallocator;
|
|
|
- if(allocator->initialized != true) {
|
|
|
- initialize_allocator(allocator);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(heap == NULL) {
|
|
|
- heap_id = map_thread_heap();
|
|
|
- heap = &allocator->heaps[heap_id];
|
|
|
- }
|
|
|
-
|
|
|
-#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
|
-
|
|
|
ptr = NULL;
|
|
|
|
|
|
#ifdef HAVE_LOCKS
|
|
@@ -160,16 +142,31 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
#ifdef HAVE_LOCKS
|
|
|
posix_unlock(heap);
|
|
|
#endif /* HAVE_LOCKS */
|
|
|
+
|
|
|
return ptr;
|
|
|
}
|
|
|
|
|
|
-/* Currently all the memory space aware allocators are pre-initialized, so
|
|
|
- * we do not expect any custom_ahmalloc call without knowing which allocator
|
|
|
- * and heap are to be used.
|
|
|
- */
|
|
|
+void * malloc(size_t size) {
|
|
|
+ allocator_t *allocator;
|
|
|
+ heap_t *heap;
|
|
|
+ int heap_id;
|
|
|
+
|
|
|
+ allocator = &systemallocator;
|
|
|
+ /* Space aware allocators have to be already initialized, no need to do
|
|
|
+ * that here. */
|
|
|
#ifndef WITH_MEMORY_SPACE_AWARENESS
|
|
|
-void * custom_malloc(size_t size) {
|
|
|
- return custom_ahmalloc(NULL, NULL, size);
|
|
|
-}
|
|
|
+ if(allocator->initialized != true) {
|
|
|
+ initialize_allocator(allocator);
|
|
|
+ }
|
|
|
+#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
|
+
|
|
|
+ /* FIXME Space aware allocators currently use one heap */
|
|
|
+#ifdef WITH_MEMORY_SPACE_AWARENESS
|
|
|
+ heap_id = 0;
|
|
|
+#else /* WITH_MEMORY_SPACE_AWARENESS */
|
|
|
+ heap_id = map_thread_heap();
|
|
|
#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
|
+ heap = &allocator->heaps[heap_id];
|
|
|
|
|
|
+ return custom_ahmalloc(allocator, heap, size);
|
|
|
+}
|