builtin: support -d builtin_free_nop to help diagnose problems with too early manual free() calls

This commit is contained in:
Delyan Angelov 2025-06-21 12:50:15 +03:00
parent 194db24829
commit dc1d091ac1
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -680,6 +680,9 @@ pub fn free(ptr voidptr) {
$if trace_free ? {
C.fprintf(C.stderr, c'free ptr: %p\n', ptr)
}
$if builtin_free_nop ? {
return
}
if ptr == unsafe { 0 } {
$if trace_free_nulls ? {
C.fprintf(C.stderr, c'free null ptr\n', ptr)