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

Simple STV temp buffer implementation

parent 19cc1e4c
...@@ -47,7 +47,11 @@ ...@@ -47,7 +47,11 @@
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static struct storage * static struct storage *
sml_stv_alloc(const struct stevedore *stv, ssize_t size, int flags) objallocwithnuke(struct worker *, const struct stevedore *, ssize_t size,
int flags);
static struct storage *
sml_stv_alloc(const struct stevedore *stv, size_t size, int flags)
{ {
struct storage *st; struct storage *st;
...@@ -161,6 +165,39 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv, ...@@ -161,6 +165,39 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
return (1); 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);
}
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
*/ */
......
...@@ -68,6 +68,9 @@ extern const struct obj_methods SML_methods; ...@@ -68,6 +68,9 @@ extern const struct obj_methods SML_methods;
struct object *SML_MkObject(const struct stevedore *, struct objcore *, struct object *SML_MkObject(const struct stevedore *, struct objcore *,
void *ptr); 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_allocobj_f SML_allocobj;
storage_panic_f SML_panic; 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