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])
37 void* xmalloc(
size_t s);
39 static inline void* zalloc(
size_t size)
41 return calloc(1, size);
44 void* xzalloc(
size_t s);
46 char* xstrdup(
const char* s);
48 void* xrealloc(
void* p,
size_t s);
50 static 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));