summaryrefslogtreecommitdiff
path: root/shells/44bsd-csh/files/patch-alloc.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2025-02-18 16:10:56 -0800
committerCy Schubert <cy@FreeBSD.org>2025-02-18 16:13:11 -0800
commitb0d746aba6a1350b4161dd33a339e7d7536437d7 (patch)
treecb3aa1914e1aa2d8e63f5df4f9acece94fdfcd27 /shells/44bsd-csh/files/patch-alloc.c
parentsysutils/kleene-cli: new port for container management (diff)
shells/44bsd-csh: Replace local functions with malloc functions
Local functions called sbrk(2) directly. sbrk(2) will disappear at some point. Removing it now reduces the sbrk footprint and allows other architectures that do not support sbrk(2) to install this port.
Diffstat (limited to 'shells/44bsd-csh/files/patch-alloc.c')
-rw-r--r--shells/44bsd-csh/files/patch-alloc.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/shells/44bsd-csh/files/patch-alloc.c b/shells/44bsd-csh/files/patch-alloc.c
new file mode 100644
index 000000000000..67a61d3183b1
--- /dev/null
+++ b/shells/44bsd-csh/files/patch-alloc.c
@@ -0,0 +1,64 @@
+--- alloc.c.orig 2025-02-18 15:59:35.263097000 -0800
++++ alloc.c 2025-02-18 16:02:58.402654000 -0800
+@@ -55,61 +55,6 @@
+ char *memtop = NULL; /* PWP: top of current memory */
+ char *membot = NULL; /* PWP: bottom of allocatable memory */
+
+-ptr_t
+-Malloc(n)
+- size_t n;
+-{
+- ptr_t ptr;
+-
+- if (membot == NULL)
+- memtop = membot = sbrk(0);
+- if ((ptr = malloc(n)) == (ptr_t) 0) {
+- child++;
+- stderror(ERR_NOMEM);
+- }
+- return (ptr);
+-}
+-
+-ptr_t
+-Realloc(p, n)
+- ptr_t p;
+- size_t n;
+-{
+- ptr_t ptr;
+-
+- if (membot == NULL)
+- memtop = membot = sbrk(0);
+- if ((ptr = realloc(p, n)) == (ptr_t) 0) {
+- child++;
+- stderror(ERR_NOMEM);
+- }
+- return (ptr);
+-}
+-
+-ptr_t
+-Calloc(s, n)
+- size_t s, n;
+-{
+- ptr_t ptr;
+-
+- if (membot == NULL)
+- memtop = membot = sbrk(0);
+- if ((ptr = calloc(s, n)) == (ptr_t) 0) {
+- child++;
+- stderror(ERR_NOMEM);
+- }
+-
+- return (ptr);
+-}
+-
+-void
+-Free(p)
+- ptr_t p;
+-{
+- if (p)
+- free(p);
+-}
+-
+ /*
+ * mstats - print out statistics about malloc
+ *