git: b0d746aba6a1 - main - shells/44bsd-csh: Replace local functions with malloc functions
Date: Wed, 19 Feb 2025 00:13:49 UTC
The branch main has been updated by cy:
URL: https://cgit.FreeBSD.org/ports/commit/?id=b0d746aba6a1350b4161dd33a339e7d7536437d7
commit b0d746aba6a1350b4161dd33a339e7d7536437d7
Author: Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2025-02-19 00:10:56 +0000
Commit: Cy Schubert <cy@FreeBSD.org>
CommitDate: 2025-02-19 00:13:11 +0000
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.
---
shells/44bsd-csh/Makefile | 2 +-
shells/44bsd-csh/files/patch-alloc.c | 64 ++++++++++++++++++++++++++++++++++++
shells/44bsd-csh/files/patch-csh.h | 17 ++++++++++
3 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/shells/44bsd-csh/Makefile b/shells/44bsd-csh/Makefile
index 51dbcc217d66..b7de07bd02f3 100644
--- a/shells/44bsd-csh/Makefile
+++ b/shells/44bsd-csh/Makefile
@@ -1,6 +1,6 @@
PORTNAME= 44bsd-csh
PORTVERSION= 20001106
-PORTREVISION= 6
+PORTREVISION= 7
CATEGORIES= shells
MASTER_SITES= LOCAL/cy
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
+ *
diff --git a/shells/44bsd-csh/files/patch-csh.h b/shells/44bsd-csh/files/patch-csh.h
new file mode 100644
index 000000000000..e69698ed338a
--- /dev/null
+++ b/shells/44bsd-csh/files/patch-csh.h
@@ -0,0 +1,17 @@
+--- csh.h.orig 2025-02-18 15:59:35.265140000 -0800
++++ csh.h 2025-02-18 16:04:08.969313000 -0800
+@@ -86,10 +86,10 @@
+ #include "char.h"
+ #include "errnum.h"
+
+-#define xmalloc(i) Malloc(i)
+-#define xrealloc(p, i) Realloc(p, i)
+-#define xcalloc(n, s) Calloc(n, s)
+-#define xfree(p) Free(p)
++#define xmalloc(i) malloc(i)
++#define xrealloc(p, i) realloc(p, i)
++#define xcalloc(n, s) calloc(n, s)
++#define xfree(p) free(p)
+
+ #include <stdio.h>
+ FILE *cshin, *cshout, *csherr;