summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/mem-pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/mem-pool.h')
-rw-r--r--libglusterfs/src/mem-pool.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h
index b3a25b25e..31f49f75c 100644
--- a/libglusterfs/src/mem-pool.h
+++ b/libglusterfs/src/mem-pool.h
@@ -110,6 +110,25 @@ void* __gf_default_realloc (void *oldptr, size_t size)
#define GF_FREE(free_ptr) __gf_free (free_ptr)
static inline
+char *gf_strndup (const char *src, size_t len)
+{
+ char *dup_str = NULL;
+
+ if (!src) {
+ goto out;
+ }
+
+ dup_str = GF_CALLOC (1, len + 1, gf_common_mt_strdup);
+ if (!dup_str) {
+ goto out;
+ }
+
+ memcpy (dup_str, src, len);
+out:
+ return dup_str;
+}
+
+static inline
char * gf_strdup (const char *src)
{
@@ -128,6 +147,21 @@ char * gf_strdup (const char *src)
return dup_str;
}
+static inline void *
+gf_memdup (const void *src, size_t size)
+{
+ void *dup_mem = NULL;
+
+ dup_mem = GF_CALLOC(1, size, gf_common_mt_strdup);
+ if (!dup_mem)
+ goto out;
+
+ memcpy (dup_mem, src, size);
+
+out:
+ return dup_mem;
+}
+
struct mem_pool {
struct list_head list;
int hot_count;
@@ -157,7 +191,6 @@ void *mem_get0 (struct mem_pool *pool);
void mem_pool_destroy (struct mem_pool *pool);
-int gf_mem_acct_is_enabled ();
-void gf_mem_acct_enable_set ();
+void gf_mem_acct_enable_set (void *ctx);
#endif /* _MEM_POOL_H */