export xfree() to Nim
This commit is contained in:
parent
ebbe604a27
commit
c868d1b62f
|
@ -42,7 +42,7 @@ proc getBacktrace*(): string {.noinline.} =
|
|||
result = newString(btLen)
|
||||
if btLen > 0:
|
||||
copyMem(addr(result[0]), bt, btLen)
|
||||
c_free(bt)
|
||||
xfree_backtrace_c(bt)
|
||||
|
||||
when defined(nimStackTraceOverride):
|
||||
registerStackTraceOverride(getBacktrace)
|
||||
|
|
|
@ -46,7 +46,7 @@ static void *xmalloc(size_t size)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void xfree(void *ptr)
|
||||
void xfree(void *ptr)
|
||||
{
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "BUG: xfree() received a NULL pointer.\n");
|
||||
|
|
|
@ -18,6 +18,8 @@ extern "C" {
|
|||
// The returned string needs to be freed by the caller.
|
||||
char *get_backtrace_c(void) __attribute__((noinline));
|
||||
|
||||
void xfree(void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
|
@ -13,3 +13,6 @@
|
|||
proc get_backtrace_c*(): cstring {.importc: "get_backtrace_c",
|
||||
header: "libbacktrace_wrapper.h".}
|
||||
|
||||
proc xfree_backtrace_c*(p: pointer) {.importc: "xfree",
|
||||
header: "libbacktrace_wrapper.h".}
|
||||
|
||||
|
|
Loading…
Reference in New Issue