mirror of
https://git.freebsd.org/ports.git
synced 2025-04-28 01:26:39 -04:00
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.
This commit is contained in:
parent
999be5f9b5
commit
b0d746aba6
3 changed files with 82 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
PORTNAME= 44bsd-csh
|
||||
PORTVERSION= 20001106
|
||||
PORTREVISION= 6
|
||||
PORTREVISION= 7
|
||||
CATEGORIES= shells
|
||||
MASTER_SITES= LOCAL/cy
|
||||
|
||||
|
|
64
shells/44bsd-csh/files/patch-alloc.c
Normal file
64
shells/44bsd-csh/files/patch-alloc.c
Normal file
|
@ -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
|
||||
*
|
17
shells/44bsd-csh/files/patch-csh.h
Normal file
17
shells/44bsd-csh/files/patch-csh.h
Normal file
|
@ -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;
|
Loading…
Add table
Reference in a new issue