From a0b93401a404a030edb7a4f91e8e366c393c066f Mon Sep 17 00:00:00 2001 From: Swann Perarnau Date: Fri, 17 Aug 2018 16:04:04 -0500 Subject: [PATCH] [refactor] use actual jemalloc flags for ourselves We are going to need more of those flags, and keeping track of the conversions is tricky. So let's use a copy of the macros. --- src/aml.h | 5 +++-- src/arena_jemalloc.c | 15 +++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/aml.h b/src/aml.h index 4888759..8450c31 100644 --- a/src/aml.h +++ b/src/aml.h @@ -122,9 +122,10 @@ int aml_vector_destroy(struct aml_vector *vector); * areas. ******************************************************************************/ +/* Arena Flags: access to useful jemalloc flags, with the same values. */ /* If passed as a flag to arena's mallocx()/reallocx() routines, the newly - * allocated memory will be 0-initialized. */ -#define AML_ARENA_FLAG_ZERO 1 + * allocated memory will be 0-initialized. */ +#define AML_ARENA_FLAG_ZERO ((int)0x40) /* opaque handle to configuration data */ struct aml_arena_data; diff --git a/src/arena_jemalloc.c b/src/arena_jemalloc.c index e6779f4..0cebfe8 100644 --- a/src/arena_jemalloc.c +++ b/src/arena_jemalloc.c @@ -175,15 +175,6 @@ static extent_hooks_t aml_arena_extent_hooks = { * Tunable by changing initialization flags ******************************************************************************/ - -int aml_arena_jemalloc_flags(int flags) -{ - int ret = 0; - if(flags & AML_ARENA_FLAG_ZERO) - ret |= MALLOCX_ZERO; - return ret; -} - /* TODO: make the function idempotent */ int aml_arena_jemalloc_register_arena(struct aml_arena_data *a, struct aml_area *area) @@ -238,7 +229,7 @@ void *aml_arena_jemalloc_mallocx(struct aml_arena_data *a, size_t sz, { struct aml_arena_jemalloc_data *arena = (struct aml_arena_jemalloc_data*) a; - int flags = arena->flags | aml_arena_jemalloc_flags(extraflags); + int flags = arena->flags | extraflags; return jemk_aml_mallocx(sz, flags); } @@ -247,7 +238,7 @@ void *aml_arena_jemalloc_reallocx(struct aml_arena_data *a, void *ptr, { struct aml_arena_jemalloc_data *arena = (struct aml_arena_jemalloc_data*) a; - int flags = arena->flags | aml_arena_jemalloc_flags(extraflags); + int flags = arena->flags | extraflags; return jemk_aml_rallocx(ptr, sz, flags); } @@ -256,7 +247,7 @@ void aml_arena_jemalloc_dallocx(struct aml_arena_data *a, void *ptr, { struct aml_arena_jemalloc_data *arena = (struct aml_arena_jemalloc_data*) a; - int flags = arena->flags | aml_arena_jemalloc_flags(extraflags); + int flags = arena->flags | extraflags; jemk_aml_dallocx(ptr, flags); } -- 2.26.2