shithub: femtolisp

Download patch

ref: bcb96ecf0f2b0d57559f806fccb12177db86db61
parent: 83d3291c689d2599c80b372646bc102c8ddc779f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Jan 16 14:20:00 EST 2025

mem: reduce noise; don't clear the allocated memory in sbrk

--- a/mem.c
+++ b/mem.c
@@ -1,6 +1,13 @@
 #include "platform.h"
 
-#if defined(USE_DLMALLOC)
+char *
+fl_strdup(const char *s)
+{
+	size_t sz = strlen(s)+1;
+	char *p = dlmalloc(sz);
+	memcpy(p, s, sz);
+	return p;
+}
 
 #if defined(__macos__)
 #include <Multiverse.h>
@@ -10,23 +17,14 @@
 	static char *e = nil;
 	if(increment == 0)
 		return e;
-	char *p = NewPtrClear(increment);
+	char *p = NewPtr(increment);
 	e = p + increment;
 	return p;
 }
 #else
-void *fl_sbrk(intptr_t increment)
+void *
+fl_sbrk(intptr_t increment)
 {
 	return sbrk(increment);
-}
-#endif
-
-char *
-fl_strdup(const char *s)
-{
-	size_t sz = strlen(s)+1;
-	char *p = dlmalloc(sz);
-	memcpy(p, s, sz);
-	return p;
 }
 #endif
--- a/meson.build
+++ b/meson.build
@@ -67,7 +67,6 @@
 platform = 'posix'
 
 src_common = [
-	'mem.c',
 	'nan.c',
 ]
 
@@ -102,6 +101,7 @@
 			language: 'c',
 		)
 		src_common += [
+			'mem.c',
 			'3rd/dlmalloc/dlmalloc.c',
 		]
 	endif