]> git.cameronkatri.com Git - mandoc.git/blob - mandoc_dbg.h
In groff commit 78e66624 on May 7 20:15:33 2021 +1000,
[mandoc.git] / mandoc_dbg.h
1 /* $Id: mandoc_dbg.h,v 1.1 2022/04/14 16:43:44 schwarze Exp $ */
2 /*
3 * Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 int mandoc_dbg_asprintf(const char *, int, char **, const char *, ...)
19 __attribute__((__format__ (__printf__, 4, 5)));
20 void *mandoc_dbg_calloc(size_t, size_t, const char *, int);
21 void *mandoc_dbg_malloc(size_t, const char *, int);
22 void *mandoc_dbg_realloc(void *, size_t, const char *, int);
23 void *mandoc_dbg_reallocarray(void *, size_t, size_t,
24 const char *, int);
25 void *mandoc_dbg_recallocarray(void *, size_t, size_t, size_t,
26 const char *, int);
27 char *mandoc_dbg_strdup(const char *, const char *, int);
28 char *mandoc_dbg_strndup(const char *, size_t, const char *, int);
29 void mandoc_dbg_free(void *, const char *, int);
30
31 void mandoc_dbg_init(int argc, char *argv[]);
32 void mandoc_dbg_name(const char *);
33 void mandoc_dbg_finish(void);
34
35 #ifndef DEBUG_NODEF
36 #define mandoc_asprintf(dest, fmt, ...) \
37 mandoc_dbg_asprintf(__FILE__, __LINE__, (dest), (fmt), __VA_ARGS__)
38 #define mandoc_calloc(num, size) \
39 mandoc_dbg_calloc((num), (size), __FILE__, __LINE__)
40 #define mandoc_malloc(size) \
41 mandoc_dbg_malloc((size), __FILE__, __LINE__)
42 #define mandoc_realloc(ptr, size) \
43 mandoc_dbg_realloc((ptr), (size), __FILE__, __LINE__)
44 #define mandoc_reallocarray(ptr, num, size) \
45 mandoc_dbg_reallocarray((ptr), (num), (size), __FILE__, __LINE__)
46 #define mandoc_recallocarray(ptr, old, num, size) \
47 mandoc_dbg_recallocarray((ptr), (old), (num), (size), \
48 __FILE__, __LINE__)
49 #define mandoc_strdup(ptr) \
50 mandoc_dbg_strdup((ptr), __FILE__, __LINE__)
51 #define mandoc_strndup(ptr, size) \
52 mandoc_dbg_strndup((ptr), (size), __FILE__, __LINE__)
53 #define free(ptr) \
54 mandoc_dbg_free((ptr), __FILE__, __LINE__)
55 #endif