29#include <uwac/config.h> 
   31#define min(a, b) (a) < (b) ? (a) : (b) 
   33#define container_of(ptr, type, member) (type*)((char*)(ptr)-offsetof(type, member)) 
   35#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0]) 
   37void* xmalloc(
size_t s);
 
   39static inline void* zalloc(
size_t size)
 
   41  return calloc(1, size);
 
   44void* xzalloc(
size_t s);
 
   46char* xstrdup(
const char* s);
 
   48void* xrealloc(
void* p, 
size_t s);
 
   50static inline char* uwac_strerror(
int dw, 
char* dmsg, 
size_t size)
 
   52#ifdef __STDC_LIB_EXT1__ 
   53  (void)strerror_s(dw, dmsg, size);
 
   54#elif defined(UWAC_HAVE_STRERROR_R) 
   55  (void)strerror_r(dw, dmsg, size);
 
   57  (void)_snprintf(dmsg, size, 
"%s", strerror(dw));