common: added mrp_datadup.
authorKrisztian Litkey <kli@iki.fi>
Wed, 25 Apr 2012 23:24:24 +0000 (02:24 +0300)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Wed, 2 May 2012 15:52:01 +0000 (18:52 +0300)
src/common/mm.h

index 27bf9e8..9b62258 100644 (file)
@@ -18,6 +18,14 @@ MRP_CDECL_BEGIN
 #define mrp_realloc(ptr, size) mrp_mm_realloc((ptr), (size), __LOC__)
 #define mrp_free(ptr)          mrp_mm_free((ptr), __LOC__)
 #define mrp_strdup(s)          mrp_mm_strdup((s), __LOC__)
+#define mrp_datadup(ptr, size) ({                      \
+           typeof(ptr) _ptr = mrp_alloc(size);         \
+                                                       \
+           if (_ptr != NULL)                           \
+               memcpy(_ptr, ptr, size);                \
+                                                       \
+           _ptr;                                       \
+       })
 
 #define mrp_allocz(size) ({                                    \
            void *_ptr;                                         \