Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Don't call sysctl every malloc, set DEBUG=1 default in fmalloc #2177

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libc/malloc/dmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ _dmalloc(size_t nbytes)
unsigned int nw, temp;

#if DEBUG == 1
sysctl(CTL_GET, "malloc.debug", &debug_level);
if (debug_level == 1) sysctl(CTL_GET, "malloc.debug", &debug_level);
#endif
if (allocs[0].ptr == 0) { /*first time*/
allocs[0].ptr = setbusy(&allocs[1]);
Expand Down
6 changes: 3 additions & 3 deletions libc/malloc/fmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <unistd.h>
#include <errno.h>
#include <sys/sysctl.h>
#define DEBUG 0 /* =1 use sysctl, =2 debug output, =3 show heap */
#define DEBUG 1 /* =1 use sysctl, =2 debug output, =3 show heap */

/* C storage allocator
* circular first-fit strategy
Expand Down Expand Up @@ -110,7 +110,7 @@ _fmalloc(size_t nbytes)
unsigned int nw, temp;

#if DEBUG == 1
sysctl(CTL_GET, "malloc.debug", &debug_level);
if (debug_level == 1) sysctl(CTL_GET, "malloc.debug", &debug_level);
#endif

debug("(%d)malloc(%5u) ", getpid(), nbytes);
Expand All @@ -137,7 +137,7 @@ _fmalloc(size_t nbytes)
/* combine free areas at heap start before allocating from free area past allocp */
//allocp = (NPTR)allocs; /* NOTE: start at last allocation for speed */
for(p=allocp; ; ) {
//f = nb = n = 0;
//int f = 0, nb = 0, n = 0;
for(temp=0; ; ) {
if(!testbusy(next(p))) {
while(!testbusy(next(q = next(p)))) {
Expand Down
Loading