]>
git.cameronkatri.com Git - mandoc.git/blob - mandoc_aux.c
1 /* $Id: mandoc_aux.c,v 1.12 2022/04/14 16:43:44 schwarze Exp $ */
3 * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
4 * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
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.
20 #include <sys/types.h>
32 #include "mandoc_aux.h"
36 mandoc_asprintf(char **dest
, const char *fmt
, ...)
42 ret
= vasprintf(dest
, fmt
, ap
);
46 err((int)MANDOCLEVEL_SYSERR
, NULL
);
51 mandoc_calloc(size_t num
, size_t size
)
55 ptr
= calloc(num
, size
);
57 err((int)MANDOCLEVEL_SYSERR
, NULL
);
62 mandoc_malloc(size_t size
)
68 err((int)MANDOCLEVEL_SYSERR
, NULL
);
73 mandoc_realloc(void *ptr
, size_t size
)
75 ptr
= realloc(ptr
, size
);
77 err((int)MANDOCLEVEL_SYSERR
, NULL
);
82 mandoc_reallocarray(void *ptr
, size_t num
, size_t size
)
84 ptr
= reallocarray(ptr
, num
, size
);
86 err((int)MANDOCLEVEL_SYSERR
, NULL
);
91 mandoc_recallocarray(void *ptr
, size_t oldnum
, size_t num
, size_t size
)
93 ptr
= recallocarray(ptr
, oldnum
, num
, size
);
95 err((int)MANDOCLEVEL_SYSERR
, NULL
);
100 mandoc_strdup(const char *ptr
)
106 err((int)MANDOCLEVEL_SYSERR
, NULL
);
111 mandoc_strndup(const char *ptr
, size_t sz
)
115 p
= strndup(ptr
, sz
);
117 err((int)MANDOCLEVEL_SYSERR
, NULL
);