From f3dbbe3f0c8072e202563b38cfba5b2407b1248e Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 5 Mar 2011 21:48:09 +0000 Subject: [PATCH] =?UTF-8?q?split=20malloc=5Fos=20and=20friends=20further?= =?UTF-8?q?=20into=20=E2=80=A2=20functions=20called=20by=20mksh=E2=80=99s?= =?UTF-8?q?=20grouping=20memory=20allocator=20=E2=80=A2=20functions=20call?= =?UTF-8?q?ed=20by=20mksh=20code=20itself?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the latter may be changed to call the internal grouping allocator, if a porter so desires (but if this were recommended, the code in question would already do so, so…) --- funcs.c | 6 +++--- lalloc.c | 10 +++++----- sh.h | 15 ++++++++++----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/funcs.c b/funcs.c index 5f05cd2..96fde1c 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.173 2011/03/05 21:43:15 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.174 2011/03/05 21:48:08 tg Exp $"); #if HAVE_KILLPG /* @@ -3605,7 +3605,7 @@ c_cat(const char **wp) char *buf, *cp; #define MKSH_CAT_BUFSIZ 4096 - if ((buf = malloc_os(MKSH_CAT_BUFSIZ)) == NULL) { + if ((buf = malloc_osfunc(MKSH_CAT_BUFSIZ)) == NULL) { bi_errorf(T_oomem, (unsigned long)MKSH_CAT_BUFSIZ); return (1); } @@ -3674,7 +3674,7 @@ c_cat(const char **wp) } while (*wp); out: - free_osmalloc(buf); + free_osfunc(buf); return (rv); } diff --git a/lalloc.c b/lalloc.c index 9aaaf27..2b9bcf9 100644 --- a/lalloc.c +++ b/lalloc.c @@ -20,13 +20,13 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.15 2011/03/05 21:43:16 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.16 2011/03/05 21:48:09 tg Exp $"); /* build with CPPFLAGS+= -DUSE_REALLOC_MALLOC=0 on ancient systems */ #if defined(USE_REALLOC_MALLOC) && (USE_REALLOC_MALLOC == 0) -#define remalloc(p,n) ((p) == NULL ? malloc_os(n) : realloc_os((p), (n))) +#define remalloc(p,n) ((p) == NULL ? malloc_osi(n) : realloc_osi((p), (n))) #else -#define remalloc(p,n) realloc_os((p), (n)) +#define remalloc(p,n) realloc_osi((p), (n)) #endif #define ALLOC_ISUNALIGNED(p) (((ptrdiff_t)(p)) % ALLOC_SIZE) @@ -113,7 +113,7 @@ afree(void *ptr, Area *ap) /* unhook */ pp->next = lp->next; /* now free ALLOC_ITEM */ - free_osmalloc(lp); + free_osimalloc(lp); } } @@ -127,6 +127,6 @@ afreeall(Area *ap) /* make next ALLOC_ITEM head of list */ ap->next = lp->next; /* free old head */ - free_osmalloc(lp); + free_osimalloc(lp); } } diff --git a/sh.h b/sh.h index ae2c4d2..8e80d25 100644 --- a/sh.h +++ b/sh.h @@ -154,7 +154,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.434 2011/03/05 21:43:18 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.435 2011/03/05 21:48:09 tg Exp $"); #endif #define MKSH_VERSION "R39 2011/02/18" @@ -500,10 +500,15 @@ char *ucstrstr(char *, const char *); /* 0. OS API: where to get memory from and how to free it (grouped) */ -/* malloc(3)/realloc(3) -> free(3) */ -#define malloc_os(sz) malloc(sz) -#define realloc_os(p,sz) realloc((p), (sz)) -#define free_osmalloc(p) free(p) +/* malloc(3)/realloc(3) -> free(3) for use by the memory allocator */ +#define malloc_osi(sz) malloc(sz) +#define realloc_osi(p,sz) realloc((p), (sz)) +#define free_osimalloc(p) free(p) + +/* malloc(3)/realloc(3) -> free(3) for use by mksh code */ +#define malloc_osfunc(sz) malloc(sz) +#define realloc_osfunc(p,sz) realloc((p), (sz)) +#define free_osfunc(p) free(p) #if HAVE_MKNOD /* setmode(3) -> free(3) */