/*
 * $Id$
 *
 * Storage method based on malloc(3)
 */

#include <assert.h>
#include <stdlib.h>
#include <sys/queue.h>
#include <pthread.h>

#include "cache.h"

struct sma {
	struct storage		s;
};

static struct storage *
sma_alloc(struct stevedore *st __unused, 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;
	sma->s.space = 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",
	NULL,			/* init */
	NULL,			/* open */
	sma_alloc,
	NULL,			/* trim */
	sma_free
};

/*
 * $Id$
 *
 * Storage method based on malloc(3)
 */

#include <assert.h>
#include <stdlib.h>
#include <sys/queue.h>
#include <pthread.h>

#include "cache.h"

struct sma {
	struct storage		s;
};

static struct storage *
sma_alloc(struct stevedore *st, 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;
	sma->s.space = size;
	sma->s.stevedore = st;
	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",
	NULL,			/* init */
	NULL,			/* open */
	sma_alloc,
	NULL,			/* trim */
	sma_free
};

Make this work again: record the stevedore in the storage object.
Make this work again: record the stevedore in the storage object.


git-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@236 d4fa192b-c00b-0410-8231-f00ffab90ce4
