Skip to content

Commit

Permalink
build.zig: Support ignore_free
Browse files Browse the repository at this point in the history
Add new enable_ignore_free option to build.zig and fix an actual bug
related to the implementation of ignore_free. That it was a comment must
have been a mistake.
  • Loading branch information
plajjan committed Mar 18, 2024
1 parent 26a0222 commit fc3f948
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub fn build(b: *std.Build) void {
"Support for atomic uncollectible allocation") orelse true;
const enable_redirect_malloc = b.option(bool, "enable_redirect_malloc",
"Redirect malloc and friend to GC routines") orelse false;
const enable_ignore_free = b.option(bool, "enable_ignore_free",
"Ignore calls to free") orelse false;
const enable_disclaim = b.option(bool, "enable_disclaim",
"Support alternative finalization interface") orelse true;
const enable_dynamic_pointer_mask = b.option(bool,
Expand Down Expand Up @@ -303,6 +305,10 @@ pub fn build(b: *std.Build) void {
}
}

if (enable_ignore_free) {
flags.append("-D IGNORE_FREE") catch unreachable;
}

if (enable_mmap or enable_munmap) {
flags.append("-D USE_MMAP") catch unreachable;
}
Expand Down
2 changes: 1 addition & 1 deletion malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ GC_API void GC_CALL GC_free(void * p)
void free(void * p)
{
# ifdef IGNORE_FREE
# UNUSED_ARG(p);
UNUSED_ARG(p);
# else
# if defined(GC_LINUX_THREADS) && !defined(USE_PROC_FOR_LIBRARIES)
/* Don't bother with initialization checks. If nothing */
Expand Down

0 comments on commit fc3f948

Please sign in to comment.