Commit f07157f7 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland Committed by Dridi Boukelmoune

Simple STV temp buffer implementation

Conflicts:
	bin/varnishd/storage/storage_simple.c
parent 1518c09d
......@@ -44,6 +44,10 @@
/*-------------------------------------------------------------------*/
static struct storage *
objallocwithnuke(struct worker *, const struct stevedore *, size_t size,
int flags);
static struct storage *
sml_stv_alloc(const struct stevedore *stv, size_t size, int flags)
{
......@@ -159,6 +163,39 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
return (1);
}
void * v_matchproto_(storage_allocbuf_t)
SML_AllocBuf(struct worker *wrk, const struct stevedore *stv, size_t size,
uintptr_t *ppriv)
{
struct storage *st;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
AN(ppriv);
if (size > UINT_MAX)
return (NULL);
st = objallocwithnuke(wrk, stv, size, 0);
if (st == NULL)
return (NULL);
assert(st->space >= size);
st->len = size;
*ppriv = (uintptr_t)st;
return (st->ptr);
}
void v_matchproto_(storage_freebuf_t)
SML_FreeBuf(struct worker *wrk, const struct stevedore *stv, uintptr_t priv)
{
struct storage *st;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CAST_OBJ_NOTNULL(st, (void *)priv, STORAGE_MAGIC);
sml_stv_free(stv, st);
}
/*---------------------------------------------------------------------
*/
......
......@@ -66,6 +66,9 @@ extern const struct obj_methods SML_methods;
struct object *SML_MkObject(const struct stevedore *, struct objcore *,
void *ptr);
void *SML_AllocBuf(struct worker *, const struct stevedore *, size_t,
uintptr_t *);
void SML_FreeBuf(struct worker *, const struct stevedore *, uintptr_t);
storage_allocobj_f SML_allocobj;
storage_panic_f SML_panic;
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