diff options
| author | mikeos <mike.osipov@gmail.com> | 2012-10-13 23:20:14 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2012-10-13 23:20:14 +0400 |
| commit | 893c216b889f260378fb21a7f576c061f7ff2248 (patch) | |
| tree | ad4566df268c76de8fc743d006b14baf6bfb6594 /xwrap.c | |
initial
Diffstat (limited to 'xwrap.c')
| -rw-r--r-- | xwrap.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#include <string.h> +#include <stdlib.h> + +#include "debug.h" + +void *xmalloc(size_t size) +{ + void *p; + + p = malloc(size); + if (p == NULL) + sys_err("malloc %zd bytes", size); + return p; +} + +char *xstrdup(const char *s) +{ + int len; + + len = strlen(s) + 1; + return memcpy(xmalloc(len), s, len); +} + |
