From: Brian Date: Wed, 6 Feb 2008 16:28:20 +0000 (-0700) Subject: gallium: added mem_dup() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8af89cf722830ec16d594afd99d717aed71d44c;p=mesa.git gallium: added mem_dup() --- diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 4780ed78184..991ac447bac 100644 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -183,6 +183,20 @@ align_free(void *ptr) +/** + * Duplicate of a block of memory + */ +static INLINE void * +mem_dup(const void *src, uint size) +{ + void *dup = malloc(size); + if (dup) + memcpy(dup, src, size); + return dup; +} + + + #define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) #define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) #define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )