Pārlūkot izejas kodu

bitmap_malloc() currently should not serve requests which occupy more than 2 bitmap vector elements

Ioannis Koutras 12 gadi atpakaļ
vecāks
revīzija
89633dd5b6
2 mainītis faili ar 15 papildinājumiem un 0 dzēšanām
  1. 6 0
      src/bitmap/bitmap_malloc.c
  2. 9 0
      src/dmmlib.c

+ 6 - 0
src/bitmap/bitmap_malloc.c

@@ -65,6 +65,12 @@ void * bitmap_malloc(raw_block_header_t *raw_block, size_t req_size) {
         cells = req_size / rb_header->bytes_per_cell;
     }
 
+    // FIXME The current implementation does not allow checking cells which
+    // lie on more than two consecutive bitmap vector elements
+    if(cells > 2 * BMAP_EL_SIZE_BITS) {
+        return NULL;
+    }
+
     stop = prev_pow2(cells);
 
 #ifdef HAVE_LOCKS

+ 9 - 0
src/dmmlib.c

@@ -118,6 +118,15 @@ void * malloc(size_t size) {
             systemallocator.raw_block_head = new_raw_block;
             pthread_mutex_unlock(&systemallocator.creation_mutex);
             ptr = dmmlib_malloc(new_raw_block, size);
+#ifdef BITMAP_RB_ONLY
+            // FIXME If ptr is still NULL, then make a last try to allocate a
+            // big block. This has to do with the current limitation of checking
+            // max. two bitmap vector elements.
+            if(ptr == NULL) {
+                ptr = (void *) create_new_raw_block(size +
+                        sizeof(raw_block_header_t), BIGBLOCK);
+            }
+#endif /* BITMAP_RB_ONLY */
         }
     }