1 /* $Id: mandoc_aux.c,v 1.3 2014/07/09 08:20:34 schwarze Exp $ */
3 * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <sys/types.h>
30 #include "mandoc_aux.h"
33 mandoc_asprintf(char **dest
, const char *fmt
, ...)
39 ret
= vasprintf(dest
, fmt
, ap
);
44 exit((int)MANDOCLEVEL_SYSERR
);
50 mandoc_calloc(size_t num
, size_t size
)
54 ptr
= calloc(num
, size
);
57 exit((int)MANDOCLEVEL_SYSERR
);
63 mandoc_malloc(size_t size
)
70 exit((int)MANDOCLEVEL_SYSERR
);
76 mandoc_realloc(void *ptr
, size_t size
)
79 ptr
= realloc(ptr
, size
);
82 exit((int)MANDOCLEVEL_SYSERR
);
88 mandoc_reallocarray(void *ptr
, size_t num
, size_t size
)
91 ptr
= reallocarray(ptr
, num
, size
);
94 exit((int)MANDOCLEVEL_SYSERR
);
100 mandoc_strdup(const char *ptr
)
107 exit((int)MANDOCLEVEL_SYSERR
);
113 mandoc_strndup(const char *ptr
, size_t sz
)
117 p
= mandoc_malloc(sz
+ 1);