|
@@ -22,24 +22,19 @@
|
|
|
* @brief malloc() implementation for freelist-organised raw blocks
|
|
|
*/
|
|
|
|
|
|
-#include "dmmlib/freelist/freelist.h"
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
-#include "freelist/fitting_policy.h"
|
|
|
-#include "freelist/block_header_funcs.h"
|
|
|
+#include <dmmlib/config.h>
|
|
|
|
|
|
-#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
|
|
|
-#include "freelist/split.h"
|
|
|
-#endif /* SPLITTING_FIXED || SPLITTING_VARIABLE */
|
|
|
+#include "dmmlib/freelist/freelist.h"
|
|
|
|
|
|
+#include "statistics.h"
|
|
|
#include "trace.h"
|
|
|
|
|
|
-#ifdef WITH_ALLOCATOR_STATS
|
|
|
-#include "locks.h"
|
|
|
-#include "statistics.h"
|
|
|
-#include "dmmlib/dmmlib.h"
|
|
|
-#endif /* WITH_ALLOCATOR_STATS */
|
|
|
+#include "freelist/block_header_funcs.h"
|
|
|
+#include "freelist/fitting_policy.h"
|
|
|
+#include "freelist/split.h"
|
|
|
|
|
|
size_t req_padding(size_t size);
|
|
|
|
|
@@ -80,14 +75,10 @@ void * freelist_malloc(freelist_rb_t *raw_block, size_t size) {
|
|
|
ptr = SEARCH_LIST(raw_block, size);
|
|
|
|
|
|
if(ptr != NULL) {
|
|
|
-#ifdef REQUEST_SIZE_INFO
|
|
|
- set_requested_size(ptr, size);
|
|
|
-#endif /* REQUEST_SIZE_INFO */
|
|
|
+ SET_REQUESTED_SIZE(ptr, size);
|
|
|
|
|
|
/* Try to split */
|
|
|
-#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
|
|
|
- split(raw_block, ptr, size);
|
|
|
-#endif /* (SPLITTING_FIXED) || (SPLITTING_VARIABLE) */
|
|
|
+ SPLIT(raw_block, ptr, size);
|
|
|
|
|
|
mark_used(raw_block, ptr);
|
|
|
} else {
|
|
@@ -114,25 +105,17 @@ void * freelist_malloc(freelist_rb_t *raw_block, size_t size) {
|
|
|
// Update block metadata
|
|
|
set_size_and_used(raw_block, ptr, req_padding(size));
|
|
|
set_previous_size_availability(ptr, previous_size_availability);
|
|
|
-#ifdef REQUEST_SIZE_INFO
|
|
|
- set_requested_size(ptr, size);
|
|
|
-#endif /* REQUEST_SIZE_INFO */
|
|
|
+ SET_REQUESTED_SIZE(ptr, size);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(ptr != NULL) {
|
|
|
|
|
|
-#ifdef WITH_ALLOCATOR_STATS
|
|
|
- LOCK_GLOBAL();
|
|
|
- update_stats
|
|
|
- ( &systemallocator.dmm_stats
|
|
|
- , MALLOC
|
|
|
#ifdef REQUEST_SIZE_INFO
|
|
|
- , size
|
|
|
+ UPDATE_GLOBAL_STATS(MALLOC, size);
|
|
|
+#else /* REQUEST_SIZE_INFO */
|
|
|
+ UPDATE_GLOBAL_STATS(MALLOC);
|
|
|
#endif /* REQUEST_SIZE_INFO */
|
|
|
- );
|
|
|
- UNLOCK_GLOBAL();
|
|
|
-#endif /* WITH_ALLOCATOR_STATS */
|
|
|
|
|
|
return (void *)((uintptr_t) ptr + HEADER_SIZE);
|
|
|
} else {
|