Procházet zdrojové kódy

release_memory() now accepts raw_block_header_t pointers directly

Ioannis Koutras před 12 roky
rodič
revize
3e768d16b1
3 změnil soubory, kde provedl 10 přidání a 14 odebrání
  1. 6 4
      private-include/release_memory.h
  2. 1 1
      src/dmmlib.c
  3. 3 9
      src/release_memory.c

+ 6 - 4
private-include/release_memory.h

@@ -1,5 +1,5 @@
 /*
- *   Copyright 2012 Institute of Communication and Computer Systems (ICCS) 
+ *   Copyright Institute of Communication and Computer Systems (ICCS) 
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -25,11 +25,13 @@
 #ifndef RELEASE_MEMORY_H
 #define RELEASE_MEMORY_H
 
+#include "dmmlib/raw_block.h"
+
 /**
- * Releases memory address space to the OS.
+ * Releases the memory space of a raw block back to the OS.
  *
- * @param address The address of the memory space to be released.
+ * @param raw_block The pointer of the raw block which is to be released.
  */
-void release_memory(void *address);
+void release_memory(raw_block_header_t *raw_block);
 
 #endif /* RELEASE_MEMORY_H */

+ 1 - 1
src/dmmlib.c

@@ -180,7 +180,7 @@ void free(void *ptr) {
         systemallocator.dmm_stats.num_free++;
 #endif /* WITH_ALLOCATOR_STATS */
 
-        release_memory(ptr);
+        release_memory(current_raw_block);
     }
 }
 

+ 3 - 9
src/release_memory.c

@@ -1,5 +1,5 @@
 /*
- *   Copyright 2012 Institute of Communication and Computer Systems (ICCS) 
+ *   Copyright Institute of Communication and Computer Systems (ICCS) 
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -26,13 +26,7 @@
 #include "release_memory.h"
 
 #include <sys/mman.h>
-#include "dmmlib/raw_block.h"
 
-void release_memory(void *address) {
-    raw_block_header_t *rb_header;
-
-    rb_header = (raw_block_header_t *)((char *)address -
-            sizeof(raw_block_header_t));
-
-    munmap((void *)rb_header, rb_header->size);
+void release_memory(raw_block_header_t *raw_block) {
+    munmap((void *)raw_block, raw_block->size);
 }