Browse Source

Fixed size info and splitting check on realloc() where next free block can be used.

Ioannis Koutras 13 years ago
parent
commit
e54f734bd0
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/custom_realloc.c

+ 4 - 3
src/custom_realloc.c

@@ -139,7 +139,9 @@ void * custom_ahrealloc(allocator_t *allocator, heap_t *heap, void *ptr, size_t
                         if(allocator->border_ptr == next_block) {
                             allocator->border_ptr = ptr;
                         }
-                        set_size_and_used(allocator, ptr, size);
+                        set_size_and_used(allocator,
+                                ptr,
+                                old_size + get_size(next_block) + HEADER_SIZE);
 
 #if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
 #ifdef SPLITTING_FIXED
@@ -149,8 +151,7 @@ void * custom_ahrealloc(allocator_t *allocator, heap_t *heap, void *ptr, size_t
                         min_split_size = heap->dmm_knobs.min_split_size;
 #endif /* SPLITTING_VARIABLE */
 
-                        if(old_size + get_size(next_block) - size >=
-                                min_split_size) {
+                        if(get_size(ptr) - size >= min_split_size) {
                             split(allocator, heap, ptr, size);
                         }
 #endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */