|
@@ -83,24 +83,6 @@ void * custom_ahrealloc(allocator_t *allocator, heap_t *heap, void *ptr, size_t
|
|
size_t min_split_size;
|
|
size_t min_split_size;
|
|
#endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */
|
|
#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 */
|
|
|
|
-
|
|
|
|
if(ptr != NULL) {
|
|
if(ptr != NULL) {
|
|
old_size = get_size(ptr);
|
|
old_size = get_size(ptr);
|
|
if(old_size > size) {
|
|
if(old_size > size) {
|
|
@@ -173,9 +155,27 @@ void * custom_ahrealloc(allocator_t *allocator, heap_t *heap, void *ptr, size_t
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void * realloc(void *ptr, 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
|
|
#ifndef WITH_MEMORY_SPACE_AWARENESS
|
|
-void * custom_realloc(void *ptr, size_t size) {
|
|
|
|
- return custom_ahrealloc(NULL, NULL, ptr, 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 */
|
|
#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
|
|
+ heap = &allocator->heaps[heap_id];
|
|
|
|
|
|
|
|
+ return custom_ahrealloc(allocator, heap, ptr, size);
|
|
|
|
+}
|