summaryrefslogtreecommitdiffstats
path: root/common.h
blob: 9957d42f9e8fd1cdc93607c61c8d01f06eaeae14 (plain)
1
2
3
4
5
6
7
8
#define psizeof(a) (sizeof(a) / sizeof(*(a)))

static inline void *memdup(void *src, size_t size) {
  void *r = malloc(size);
  memcpy(r, src, size);
  return r;
}
#define ifree(p) do { if (p) { free(p); p = NULL; } } while (0)