we do not need the group backpointer, except for a (very little) amount
of sanitising; since this is supposed to be the lightweight allocator, with the guarding allocator coming back in later, remove it reduces memory consumption below what espie's allocator used ☺
This commit is contained in:
parent
44202462f5
commit
ebfce0fafd
15
lalloc.c
15
lalloc.c
@ -1,6 +1,6 @@
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.3 2009/03/23 10:31:15 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.4 2009/03/24 08:37:37 tg Exp $");
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#ifdef SIZE_T_MAX
|
||||
@ -12,7 +12,6 @@ __RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.3 2009/03/23 10:31:15 tg Exp $");
|
||||
|
||||
struct lalloc {
|
||||
struct lalloc *next; /* entry pointer, must be first */
|
||||
Area *group; /* group backpointer */
|
||||
};
|
||||
|
||||
static void findptr(struct lalloc **, struct lalloc **, char *, Area *);
|
||||
@ -27,13 +26,10 @@ static void
|
||||
findptr(struct lalloc **lpp, struct lalloc **ppp, char *ptr, Area *ap)
|
||||
{
|
||||
*lpp = (struct lalloc *)(ptr - sizeof (struct lalloc));
|
||||
if ((*lpp)->group != ap)
|
||||
notfound:
|
||||
internal_errorf("pointer %p not in group %p", ptr, ap);
|
||||
*ppp = (struct lalloc *)ap;
|
||||
while ((*ppp)->next != *lpp)
|
||||
if (((*ppp) = (*ppp)->next) == NULL)
|
||||
goto notfound;
|
||||
internal_errorf("pointer %p not in group %p", ptr, ap);
|
||||
}
|
||||
|
||||
void *
|
||||
@ -57,7 +53,6 @@ aresize(void *ptr, size_t numb, Area *ap)
|
||||
(unsigned long)numb);
|
||||
}
|
||||
if (ptr == NULL) {
|
||||
lp->group = ap;
|
||||
lp->next = ap->ent;
|
||||
}
|
||||
pp->next = lp;
|
||||
@ -74,7 +69,6 @@ afree(void *ptr, Area *ap)
|
||||
|
||||
findptr(&lp, &pp, ptr, ap);
|
||||
pp->next = lp->next;
|
||||
/* lp->group = NULL; */
|
||||
free(lp);
|
||||
}
|
||||
|
||||
@ -84,12 +78,7 @@ afreeall(Area *ap)
|
||||
struct lalloc *lp;
|
||||
|
||||
while ((lp = ap->ent) != NULL) {
|
||||
#ifndef MKSH_SMALL
|
||||
if (lp->group != ap)
|
||||
internal_errorf("rogue pointer in group %p", ap);
|
||||
#endif
|
||||
ap->ent = lp->next;
|
||||
/* lp->group = NULL; */
|
||||
free(lp);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user