=================================================================== RCS file: /cvs/mandoc/mandoc.c,v retrieving revision 1.3 retrieving revision 1.5 diff -u -p -r1.3 -r1.5 --- mandoc/mandoc.c 2009/07/24 20:22:24 1.3 +++ mandoc/mandoc.c 2009/10/30 05:58:38 1.5 @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.3 2009/07/24 20:22:24 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.5 2009/10/30 05:58:38 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "libmandoc.h" @@ -103,3 +105,61 @@ mandoc_special(const char *p) return(*p == ']' ? c : 0); } + +void * +mandoc_calloc(size_t num, size_t size) +{ + void *ptr; + + ptr = calloc(num, size); + if (NULL == ptr) { + fprintf(stderr, "memory exhausted\n"); + exit(EXIT_FAILURE); + } + + return(ptr); +} + + +void * +mandoc_malloc(size_t size) +{ + void *ptr; + + ptr = malloc(size); + if (NULL == ptr) { + fprintf(stderr, "memory exhausted\n"); + exit(EXIT_FAILURE); + } + + return(ptr); +} + + +void * +mandoc_realloc(void *ptr, size_t size) +{ + + ptr = realloc(ptr, size); + if (NULL == ptr) { + fprintf(stderr, "memory exhausted\n"); + exit(EXIT_FAILURE); + } + + return(ptr); +} + + +char * +mandoc_strdup(const char *ptr) +{ + char *p; + + p = strdup(ptr); + if (NULL == p) { + fprintf(stderr, "memory exhausted\n"); + exit(EXIT_FAILURE); + } + + return(p); +}