flybrain/services/flysim/vendor/binjgb/src/memory.c
acamilo 660c3cf00d
Some checks failed
ci / node 22 (test + typecheck) (push) Has been cancelled
ci / rust stable (cargo test --workspace --release) (push) Has been cancelled
ci / infra/tests/lint.sh (push) Has been cancelled
ci / playwright apps/stage (allowed to fail) (push) Has been cancelled
flybrain v0.4.0: public tree (history retained privately)
2026-09-21 15:09:46 +00:00

48 lines
1.2 KiB
C

/*
* Copyright (C) 2018 Ben Smith
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#include "memory.h"
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#if TRACE_MEMORY
void* xmalloc_(const char* file, int line, size_t size) {
void* p = malloc(size);
printf("%s:%d: %s(%" PRIu64 ") => %p\n", file, line, __func__, (uint64_t)size,
p);
return p;
}
void* xrealloc_(const char* file, int line, void* p, size_t size) {
void* newp = realloc(size);
printf("%s:%d: %s(%p, %" PRIu64 ") => %p\n", file, line, __func__, p,
(uint64_t)size, newp);
return newp;
}
void xfree_(const char* file, int line, void* p) {
printf("%s:%d: %s(%p)\n", file, line, __func__, p);
free(p);
}
void* xcalloc_(const char* file, int line, size_t count, size_t size) {
void* p = calloc(count, size);
printf("%s:%d: %s(%" PRIu64 ", %" PRIu64 ") => %p\n", file, line, __func__,
(uint64_t)count, (uint64_t)size, p);
return p;
}
char* xstrdup_(const char* file, int line, const char* s) {
char* p = strdup(s);
printf("%s:%d: %s(%p) => %p\n", file, line, __func__, s, p);
return p;
}
#endif