bin/varnishd/storage/storage_file.c
static void
free_smf(struct smf *sp)
{
	struct smf *sp2;
	struct smf_sc *sc = sp->sc;

	CHECK_OBJ_NOTNULL(sp, SMF_MAGIC);
	AN(sp->alloc);
	assert(sp->size > 0);
	AZ(sp->size % sc->pagesize);
	VTAILQ_REMOVE(&sc->used, sp, status);
	sp->alloc = 0;

	sp2 = VTAILQ_NEXT(sp, order);
	if (sp2 != NULL &&
	    sp2->alloc == 0 &&
	    (sp2->ptr == sp->ptr + sp->size) &&
	    (sp2->offset == sp->offset + sp->size)) {
		sp->size += sp2->size;
		VTAILQ_REMOVE(&sc->order, sp2, order);
		remfree(sc, sp2);
		free(sp2);
		sc->stats->g_smf--;
	}

	sp2 = VTAILQ_PREV(sp, smfhead, order);
	if (sp2 != NULL &&
	    sp2->alloc == 0 &&
	    (sp->ptr == sp2->ptr + sp2->size) &&
	    (sp->offset == sp2->offset + sp2->size)) {
		remfree(sc, sp2);
		sp2->size += sp->size;
		VTAILQ_REMOVE(&sc->order, sp, order);
		free(sp);
		sc->stats->g_smf--;
		sp = sp2;
	}

	insfree(sc, sp);
}
/*--------------------------------------------------------------------
 * Free a range.  Attempt merge forward and backward, then sort into
 * free list according to age.
 */
Free a range.  Attempt merge forward and backward, then sort into
free list according to age.
Free a range . Attempt merge forward and backward then sort into free list according to age .
static void
free_smf(struct smf *sp)
{
	struct smf *sp2;
	struct smf_sc *sc = sp->sc;
	CHECK_OBJ_NOTNULL(sp, SMF_MAGIC);
	AN(sp->alloc);
	assert(sp->size > 0);
	AZ(sp->size % sc->pagesize);
	VTAILQ_REMOVE(&sc->used, sp, status);
	sp->alloc = 0;
	sp2 = VTAILQ_NEXT(sp, order);
	if (sp2 != NULL &&
	    sp2->alloc == 0 &&
	    (sp2->ptr == sp->ptr + sp->size) &&
	    (sp2->offset == sp->offset + sp->size)) {
		sp->size += sp2->size;
		VTAILQ_REMOVE(&sc->order, sp2, order);
		remfree(sc, sp2);
		free(sp2);
		sc->stats->g_smf--;
	}
	sp2 = VTAILQ_PREV(sp, smfhead, order);
	if (sp2 != NULL &&
	    sp2->alloc == 0 &&
	    (sp->ptr == sp2->ptr + sp2->size) &&
	    (sp->offset == sp2->offset + sp2->size)) {
		remfree(sc, sp2);
		sp2->size += sp->size;
		VTAILQ_REMOVE(&sc->order, sp, order);
		free(sp);
		sc->stats->g_smf--;
		sp = sp2;
	}
	insfree(sc, sp);
}
static void free_smf ( struct smf * sp ) { struct smf * sp2 ; struct smf_sc * sc = sp -> sc ; CHECK_OBJ_NOTNULL ( sp , SMF_MAGIC ) ; AN ( sp -> alloc ) ; assert ( sp -> size > 0 ) ; AZ ( sp -> size % sc -> pagesize ) ; VTAILQ_REMOVE ( & sc -> used , sp , status ) ; sp -> alloc = 0 ; sp2 = VTAILQ_NEXT ( sp , order ) ; if ( sp2 != NULL && sp2 -> alloc == 0 && ( sp2 -> ptr == sp -> ptr + sp -> size ) && ( sp2 -> offset == sp -> offset + sp -> size ) ) { sp -> size += sp2 -> size ; VTAILQ_REMOVE ( & sc -> order , sp2 , order ) ; remfree ( sc , sp2 ) ; free ( sp2 ) ; sc -> stats -> g_smf -- ; } sp2 = VTAILQ_PREV ( sp , smfhead , order ) ; if ( sp2 != NULL && sp2 -> alloc == 0 && ( sp -> ptr == sp2 -> ptr + sp2 -> size ) && ( sp -> offset == sp2 -> offset + sp2 -> size ) ) { remfree ( sc , sp2 ) ; sp2 -> size += sp -> size ; VTAILQ_REMOVE ( & sc -> order , sp , order ) ; free ( sp ) ; sc -> stats -> g_smf -- ; sp = sp2 ; } insfree ( sc , sp ) ; }
Free a range.
Free a range .