diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-10 19:01:39 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-10 19:01:39 +0200 |
commit | 320f600cd980230b2b2e34c7256c9564af6afae9 (patch) | |
tree | fd64b3545a386255ddccb71d3f97dd141b0d14a9 /utils.h | |
parent | af7dbbcbc9fe89deb4951d45b0f6ce839199c88b (diff) |
Add some basic memory tracking infrastructure while hacking
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -79,10 +79,15 @@ static inline bool list_empty(struct list_head *list) &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) -static inline void* zmalloc(size_t size) -{ - return calloc(1, size); -} +#define zmalloc(s) ({ fprintf(stderr, "Alloc: zmalloc called from %s: %zu\n", __func__, s); __zmalloc(s); }) +void *__zmalloc(size_t s); + +#define xstrdup(s) ({ fprintf(stderr, "Alloc: xstrdup called from %s: %zu\n", __func__, strlen(s) + 1); __xstrdup(s); }) +char *__xstrdup(const char *s); + +void xfree(void *ptr); + +void debug_resource_usage(); #define ADDRSTRLEN (9 /*strlen("AF_INETX ")*/ + INET6_ADDRSTRLEN + 6 /*strlen(" 65535")*/ + 1) struct sockaddr_in46 { |