diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-06 00:45:52 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-06 00:45:52 +0800 |
commit | 8e633ab936625fa1e897c5c062f70705996e7b85 (patch) | |
tree | 3e2bcf12e7584983749e6616123f8e36096b8e86 /src/memalloc.c | |
parent | [MEMALLOC] Made grabstackblock an inline wrapper for stalloc (diff) | |
download | dash-8e633ab936625fa1e897c5c062f70705996e7b85.tar.gz dash-8e633ab936625fa1e897c5c062f70705996e7b85.zip |
[MEMALLOC] Add pushstackmark
This patch gets rid of the stack mark tracking hack by allocating a little bit of stack memory if we're at risk of planting a stack mark which may be grown later. To do this a new function pushstackmark is added which lets the user pick a bigger amount to allocate since some users do that anyway after setting a stack mark.
Diffstat (limited to '')
-rw-r--r-- | src/memalloc.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/memalloc.c b/src/memalloc.c index c8147d3..8d3e2ed 100644 --- a/src/memalloc.c +++ b/src/memalloc.c @@ -106,7 +106,6 @@ struct stack_block { struct stack_block stackbase; struct stack_block *stackp = &stackbase; -struct stackmark *markp; char *stacknxt = stackbase.space; size_t stacknleft = MINSIZE; char *sstrend = stackbase.space + MINSIZE; @@ -161,14 +160,17 @@ stunalloc(pointer p) -void -setstackmark(struct stackmark *mark) +void pushstackmark(struct stackmark *mark, size_t len) { mark->stackp = stackp; mark->stacknxt = stacknxt; mark->stacknleft = stacknleft; - mark->marknext = markp; - markp = mark; + grabstackblock(len); +} + +void setstackmark(struct stackmark *mark) +{ + pushstackmark(mark, stacknxt == stackp->space && stackp != &stackbase); } @@ -178,7 +180,6 @@ popstackmark(struct stackmark *mark) struct stack_block *sp; INTOFF; - markp = mark->marknext; while (stackp != mark->stackp) { sp = stackp; stackp = sp->prev; @@ -214,7 +215,6 @@ growstackblock(void) if (stacknxt == stackp->space && stackp != &stackbase) { struct stack_block *oldstackp; - struct stackmark *xmark; struct stack_block *sp; struct stack_block *prevstackp; size_t grosslen; @@ -230,18 +230,6 @@ growstackblock(void) stacknxt = sp->space; stacknleft = newlen; sstrend = sp->space + newlen; - - /* - * Stack marks pointing to the start of the old block - * must be relocated to point to the new block - */ - xmark = markp; - while (xmark != NULL && xmark->stackp == oldstackp) { - xmark->stackp = stackp; - xmark->stacknxt = stacknxt; - xmark->stacknleft = stacknleft; - xmark = xmark->marknext; - } INTON; } else { char *oldspace = stacknxt; |