diff options
| author | Stefan Farfeleder <stefanf@FreeBSD.org> | 2005-10-28 10:45:19 +0000 |
|---|---|---|
| committer | Stefan Farfeleder <stefanf@FreeBSD.org> | 2005-10-28 10:45:19 +0000 |
| commit | 670528cd789a9ce3d51e32edddc02e6b7ff358f9 (patch) | |
| tree | 90a53b77b5ce252eb80e70be38ddf646e528c634 /bin/sh | |
| parent | b923a71020ae338f723d9aa01b5365c90aae2fec (diff) | |
Notes
Diffstat (limited to 'bin/sh')
| -rw-r--r-- | bin/sh/memalloc.c | 18 | ||||
| -rw-r--r-- | bin/sh/memalloc.h | 3 | ||||
| -rw-r--r-- | bin/sh/miscbltin.c | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index 60f9203d7da1..115eea03df7b 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -57,7 +57,10 @@ ckmalloc(int nbytes) { pointer p; - if ((p = malloc(nbytes)) == NULL) + INTOFF; + p = malloc(nbytes); + INTON; + if (p == NULL) error("Out of space"); return p; } @@ -70,11 +73,22 @@ ckmalloc(int nbytes) pointer ckrealloc(pointer p, int nbytes) { - if ((p = realloc(p, nbytes)) == NULL) + INTOFF; + p = realloc(p, nbytes); + INTON; + if (p == NULL) error("Out of space"); return p; } +void +ckfree(pointer p) +{ + INTOFF; + free(p); + INTON; +} + /* * Make a copy of a string in safe storage. diff --git a/bin/sh/memalloc.h b/bin/sh/memalloc.h index 254d27ba44c0..347544211f51 100644 --- a/bin/sh/memalloc.h +++ b/bin/sh/memalloc.h @@ -48,6 +48,7 @@ extern int herefd; pointer ckmalloc(int); pointer ckrealloc(pointer, int); +void ckfree(pointer); char *savestr(char *); pointer stalloc(int); void stunalloc(pointer); @@ -72,5 +73,3 @@ void ungrabstackstr(char *, char *); #define STTOPC(p) p[-1] #define STADJUST(amount, p) (p += (amount), sstrnleft -= (amount)) #define grabstackstr(p) stalloc(stackblocksize() - sstrnleft) - -#define ckfree(p) free((pointer)(p)) diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index d36f9e39ffeb..7c8981bb6829 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -274,12 +274,14 @@ umaskcmd(int argc __unused, char **argv) umask(mask); } else { void *set; + INTOFF; if ((set = setmode (ap)) == 0) error("Illegal number: %s", ap); mask = getmode (set, ~mask & 0777); umask(~mask & 0777); free(set); + INTON; } } return 0; |
