cli_event.c \
hash_simple_list.c \
mgt_child.c \
+ storage_malloc.c \
tcp.c \
varnishd.c
extern struct hash_slinger hsl_slinger;
+/* Storage -----------------------------------------------------------*/
+
+struct storage {
+ TAILQ_ENTRY(storage) list;
+ void *ptr;
+ unsigned len;
+ void *priv;
+};
+
+typedef void storage_init_f(void);
+typedef struct storage *storage_alloc_f(unsigned size);
+typedef void storage_free_f(struct storage *);
+
+struct stevedore {
+ const char *name;
+ storage_init_f *init;
+ storage_alloc_f *alloc;
+ storage_free_f *free;
+};
+
+extern struct stevedore sma_stevedore;
+
/* Prototypes etc ----------------------------------------------------*/
--- /dev/null
+/*
+ * $Id$
+ *
+ * Storage method based on malloc(3)
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/queue.h>
+#include <pthread.h>
+
+#include "vcl_lang.h"
+#include "cache.h"
+
+struct sma {
+ struct storage s;
+};
+
+static void
+sma_init(void)
+{
+}
+
+static struct storage *
+sma_alloc(unsigned size)
+{
+ struct sma *sma;
+
+ sma = calloc(sizeof *sma, 1);
+ assert(sma != NULL);
+ sma->s.priv = sma;
+ sma->s.ptr = malloc(size);
+ assert(sma->s.ptr != NULL);
+ sma->s.len = size;
+ return (&sma->s);
+}
+
+static void
+sma_free(struct storage *s)
+{
+ struct sma *sma;
+
+ sma = s->priv;
+ free(sma->s.ptr);
+ free(sma);
+}
+
+struct stevedore sma_stevedore = {
+ "Malloc",
+ sma_init,
+ sma_alloc,
+ sma_free
+};