Mildly working build process with argument parsing

This commit is contained in:
David Adrian
2013-09-19 17:51:49 -04:00
parent 8607c2574b
commit 8db9f260f2
17 changed files with 3578 additions and 613 deletions

44
lib/xalloc.c Normal file
View File

@ -0,0 +1,44 @@
#include "xalloc.h"
#include "../lib/logger.h"
#include <stdlib.h>
void die() __attribute__((noreturn));
void* xcalloc(size_t count, size_t size)
{
void* res = calloc(count, size);
if (res == NULL) {
die();
}
return res;
}
void xfree(void *ptr)
{
free(ptr);
}
void* xmalloc(size_t size)
{
void* res = malloc(size);
if (res == NULL) {
die();
}
return res;
}
void* xrealloc(void *ptr, size_t size)
{
void* res = realloc(ptr, size);
if (res == NULL) {
die();
}
return res;
}
void die()
{
log_fatal("zmap", "Out of memory");
}

14
lib/xalloc.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef ZMAP_ALLOC_H
#define ZMAP_ALLOC_H
#include <stddef.h>
void* xcalloc(size_t count, size_t size);
void xfree(void *ptr);
void* xmalloc(size_t size);
void* xrealloc(void *ptr, size_t size);
#endif