give hints to anew() according to aalloc stats output for testsuite and a

little interactive use, to reduce the number realloc(3) must be called
This commit is contained in:
tg 2008-11-15 09:00:19 +00:00
parent 6be05862db
commit 546d5d0def
3 changed files with 9 additions and 9 deletions

4
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.145 2008/11/15 07:35:23 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.146 2008/11/15 09:00:18 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -2681,7 +2681,7 @@ x_init_emacs(void)
{ {
int i, j; int i, j;
AEDIT = anew(0); AEDIT = anew(8);
x_nextcmd = -1; x_nextcmd = -1;
x_tab = alloc(X_NTABS, sizeof (*x_tab), AEDIT); x_tab = alloc(X_NTABS, sizeof (*x_tab), AEDIT);

10
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.112 2008/11/15 08:42:35 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.113 2008/11/15 09:00:19 tg Exp $");
extern char **environ; extern char **environ;
@ -91,11 +91,11 @@ main(int argc, const char *argv[])
} }
kshname = *argv; kshname = *argv;
APERM = anew(0); /* initialise permanent Area */ APERM = anew(256); /* initialise permanent Area */
/* set up base environment */ /* set up base environment */
env.type = E_NONE; env.type = E_NONE;
env.areap = anew(0); env.areap = anew(32);
newblock(); /* set up global l->vars and l->funs */ newblock(); /* set up global l->vars and l->funs */
/* Do this first so output routines (eg, errorf, shellf) can work */ /* Do this first so output routines (eg, errorf, shellf) can work */
@ -614,7 +614,7 @@ newenv(int type)
ep = alloc(1, sizeof (struct env), ATEMP); ep = alloc(1, sizeof (struct env), ATEMP);
ep->type = type; ep->type = type;
ep->flags = 0; ep->flags = 0;
ep->areap = anew(0); ep->areap = anew(16);
ep->loc = e->loc; ep->loc = e->loc;
ep->savefd = NULL; ep->savefd = NULL;
ep->oenv = e; ep->oenv = e;
@ -720,7 +720,7 @@ reclaim(bool finish)
e->temps = NULL; e->temps = NULL;
adelete(&e->areap); adelete(&e->areap);
if (!finish) if (!finish)
e->areap = anew(0); e->areap = anew(16);
} }
static void static void

4
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.61 2008/11/15 07:35:25 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/var.c,v 1.62 2008/11/15 09:00:19 tg Exp $");
/* /*
* Variables * Variables
@ -39,7 +39,7 @@ newblock(void)
l = alloc(1, sizeof (struct block), ATEMP); l = alloc(1, sizeof (struct block), ATEMP);
l->flags = 0; l->flags = 0;
l->areap = anew(0); /* TODO: could use e->area */ l->areap = anew(Flag(FTALKING) ? 1024 : 64);
if (!e->loc) { if (!e->loc) {
l->argc = 0; l->argc = 0;
l->argv = empty; l->argv = empty;