diff options
author | Kinglong Mee <mijinlong@open-fs.com> | 2017-08-30 17:54:09 +0800 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-09-01 15:32:55 +0000 |
commit | d7ccdb33c2e84bab25bf0898866104f8a85b4217 (patch) | |
tree | 451568625f26dc732e52c318f414e777c8b2e19a /libglusterfs | |
parent | 75223c0a1b3c7bd65bb0c59449ed1fb0663cfdd3 (diff) |
gfapi: adds a glfs_mem_header for exported memory
glfs_free releases different types of data depends on memory type.
Drop the depends of memory type of memory accounting,
new macro GLFS_CALLOC/GLFS_MALLOC/GLFS_REALLOC/GLFS_FREE are added
to support assign release function dynamically, it adds a separate
memory header named glfs_mem_header for gfapi.
Updates: #312
Change-Id: Ie608e5227cbaa05d3f4681a515e83a50d5b17c3f
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Reviewed-on: https://review.gluster.org/18092
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/mem-pool.c | 33 | ||||
-rw-r--r-- | libglusterfs/src/mem-pool.h | 3 |
2 files changed, 0 insertions, 36 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 328c8071e29..4d2c324baa2 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -328,39 +328,6 @@ free: FREE (ptr); } - -/* - * Based on the mem-type that is used for the allocation, GF_FREE can be - * called, or something more intelligent for the structure can be done. - * - * NOTE: this will not work for allocations from a memory pool. It never did, - * because those allocations never set the type in the first place. Any caller - * that relies on knowing whether a particular type was allocated via a pool or - * not is *BROKEN*, or will be any time either this module or the module - * "owning" the type changes. The proper way to handle this, assuming the - * caller is not smart enough to call a type-specific free function themselves, - * would be to create a callback interface where destructors for specific types - * can be registered so that code *here* (GF_FREE, mem_put, etc.) can do the - * right thing. That allows type-specific behavior without creating the kind - * of fragile coupling that we have now. - */ -int -gf_get_mem_type (void *ptr) -{ - struct mem_header *header = NULL; - - if (!ptr || !THIS->ctx->mem_acct_enable) - return 0; - - header = (struct mem_header *) (ptr - GF_MEM_HEADER_SIZE); - - /* Possible corruption, assert here */ - GF_ASSERT (GF_MEM_HEADER_MAGIC == header->magic); - - return header->type; -} - - #define POOL_SMALLEST 7 /* i.e. 128 */ #define POOL_LARGEST 20 /* i.e. 1048576 */ #define NPOOLS (POOL_LARGEST - POOL_SMALLEST + 1) diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h index ff5d183b16d..e68e00dfca1 100644 --- a/libglusterfs/src/mem-pool.h +++ b/libglusterfs/src/mem-pool.h @@ -92,9 +92,6 @@ gf_asprintf (char **string_ptr, const char *format, ...); void __gf_free (void *ptr); -int -gf_get_mem_type (void *ptr); - static inline void* __gf_default_malloc (size_t size) { |