Browse Source

align the raw block's size before the memory request

Ioannis Koutras 12 years ago
parent
commit
68007b4a34
1 changed files with 7 additions and 7 deletions
  1. 7 7
      src/raw_block.c

+ 7 - 7
src/raw_block.c

@@ -43,6 +43,13 @@ raw_block_header_t *create_raw_block(size_t raw_block_size, rb_type type) {
     size_t remaining_cells;
 #endif /* BITMAP_RB_ONLY */
 
+    // In case mmap() function is used, align the requested size to multiple of
+    // pagesizes
+#ifdef PAGESIZE_ALIGN
+    size_t pagesize = (size_t) sysconf(_SC_PAGESIZE);
+    raw_block_size = pagesize * ((raw_block_size + pagesize - 1) / pagesize);
+#endif /* PAGESIZE_ALIGN */
+
     ptr = (raw_block_header_t *)request_memory(raw_block_size);
 
     if(ptr == NULL) {
@@ -56,13 +63,6 @@ raw_block_header_t *create_raw_block(size_t raw_block_size, rb_type type) {
     ptr->requested_size = raw_block_size;
 #endif /* REQUEST_SIZE_INFO */
 
-    // In case mmap() function is used, align the requested size to multiple of
-    // pagesizes
-#ifdef PAGESIZE_ALIGN
-    size_t pagesize = (size_t) sysconf(_SC_PAGESIZE);
-    raw_block_size = pagesize * ((raw_block_size + pagesize - 1) / pagesize);
-#endif /* PAGESIZE_ALIGN */
-
     ptr->size = raw_block_size;
 
     switch(type) {