diff options
| author | Raghavendra G <raghavendra@gluster.com> | 2012-10-29 12:41:03 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2012-11-21 01:41:12 -0800 | 
| commit | 79eb7c62e27d01d14b3053f9ecd14d6b964bac76 (patch) | |
| tree | d8b936a1abb5e89385a43868847af58213e7bb9e /libglusterfs/src/mem-pool.h | |
| parent | bc3253b070ee9bf44360e258046a07c5630661bc (diff) | |
libglusterfs: implement gf_strndup
Change-Id: Ifb7bf22e8cf4ad1faccf7999c36919693912093f
BUG: 808400
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Reviewed-on: http://review.gluster.org/4135
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src/mem-pool.h')
| -rw-r--r-- | libglusterfs/src/mem-pool.h | 19 | 
1 files changed, 19 insertions, 0 deletions
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h index 4361c936d88..63264c75495 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)  {  | 
