summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/mem-pool.c20
-rw-r--r--libglusterfs/src/mem-pool.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 93a1415a75a..78fecec4b0f 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -338,6 +338,26 @@ free:
}
+/* 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.
+ */
+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;
+}
+
+
struct mem_pool *
mem_pool_new_fn (unsigned long sizeof_type,
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h
index 5115cef9f93..6cff7be94f4 100644
--- a/libglusterfs/src/mem-pool.h
+++ b/libglusterfs/src/mem-pool.h
@@ -97,6 +97,8 @@ 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)