Selaa lähdekoodia

Set earlier the border pointer in order to avoid wrong previous size values after split

Ioannis Koutras 13 vuotta sitten
vanhempi
commit
748f9d4401
1 muutettua tiedostoa jossa 10 lisäystä ja 10 poistoa
  1. 10 10
      src/split.c

+ 10 - 10
src/split.c

@@ -26,15 +26,17 @@ void split(allocator_t *allocator, heap_t *heap, void *ptr,
     size_t min_split_size;
     void *new_block;
     size_t new_block_size;
+#ifdef WITH_FIXED_LISTS
+    int fixed_list_id, i;
+    maptable_node_t *current_maptable_node;
+#endif /* WITH_FIXED_LISTS */
 #ifdef COALESCE_AFTER_SPLIT
     size_t max_coal_size;
     void *next_block;
     size_t current_next_size;
+
+    next_block = get_dlnext(allocator, ptr);
 #endif /* COALESCE_AFTER_SPLIT */
-#ifdef WITH_FIXED_LISTS
-    int fixed_list_id, i;
-    maptable_node_t *current_maptable_node;
-#endif /* WITH_FIXED_LISTS */
 
     /* Check what would be the size of the new block if we split the current
      * one.
@@ -61,6 +63,10 @@ void split(allocator_t *allocator, heap_t *heap, void *ptr,
     new_block = (void *)((char *)ptr + req_size + HEADER_SIZE);
     new_block_size = get_size(ptr) - req_size - HEADER_SIZE;
 
+    if(allocator->border_ptr == ptr) {
+        allocator->border_ptr = new_block;
+    }
+
     /* Resize the previous, to be used block */
     set_size_and_used(allocator, ptr, req_size);
 
@@ -73,7 +79,6 @@ void split(allocator_t *allocator, heap_t *heap, void *ptr,
     max_coal_size = heap->dmm_knobs.max_coalesce_size;
 #endif /* COALESCING_VARIABLE */
 
-    next_block = get_dlnext(allocator, ptr);
     if(next_block != NULL) {
         if(is_free(next_block) == true) {
 #ifdef WITH_OWNERSHIP
@@ -100,7 +105,6 @@ void split(allocator_t *allocator, heap_t *heap, void *ptr,
 #endif /* COALESCE_AFTER_SPLIT */
 
     set_size_and_free(allocator, new_block, new_block_size);
-    set_previous_size_availability(new_block, get_size_availability(ptr));
 
 #ifdef WITH_FIXED_LISTS
     /* FIXME code from custom_free, some refactoring maybe?
@@ -154,8 +158,4 @@ void split(allocator_t *allocator, heap_t *heap, void *ptr,
     set_owner(new_block, heap);
 #endif /* WITH_OWNERSHIP */
 
-    if(allocator->border_ptr == ptr) {
-        allocator->border_ptr = new_block;
-    }
-
 }