Commit f8968e87 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Implement ->trim()


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@245 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent b3146d8c
......@@ -346,6 +346,29 @@ free_smf(struct smf *sp)
TAILQ_INSERT_TAIL(&sc->free, sp, status);
}
/*--------------------------------------------------------------------
* Trim the tail of a range.
*/
static void
trim_smf(struct smf *sp, size_t bytes)
{
struct smf *sp2;
struct smf_sc *sc = sp->sc;
assert(bytes > 0);
sp2 = malloc(sizeof *sp2);
assert(sp2 != NULL);
sp2->size = sp->size - bytes;
sp->size = bytes;
sp2->ptr = sp->ptr + bytes;
sp2->offset = sp->offset + bytes;
TAILQ_INSERT_TAIL(&sc->used, sp2, status);
TAILQ_INSERT_AFTER(&sc->order, sp, sp2, status);
free_smf(sp2);
}
/*--------------------------------------------------------------------
* Insert a newly created range as busy, then free it to do any collapses
*/
......@@ -463,8 +486,15 @@ smf_alloc(struct stevedore *st, unsigned size)
static void
smf_trim(struct storage *s, size_t size)
{
struct smf *smf;
struct smf_sc *sc = s->priv;
/* XXX: implement */
assert(size > 0);
size += (sc->pagesize - 1);
size &= ~(sc->pagesize - 1);
smf = (struct smf *)(s->priv);
if (smf->size > size)
trim_smf(smf, size);
}
/*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment