/*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: odr_mem.c,v 1.7 2006-02-19 18:33:09 adam Exp $
+ * $Id: odr_mem.c,v 1.12 2007-09-11 08:35:42 adam Exp $
*/
/**
* \file odr_mem.c
{
NMEM r = o->mem;
- o->mem = 0;
+ o->mem = nmem_create();
return r;
}
void *odr_malloc(ODR o, int size)
{
- if (o && !o->mem)
- o->mem = nmem_create();
- return nmem_malloc(o ? o->mem : 0, size);
+ return nmem_malloc(o->mem, size);
}
char *odr_strdup(ODR o, const char *str)
{
- if (o && !o->mem)
- o->mem = nmem_create();
return nmem_strdup(o->mem, str);
}
+char *odr_strdup_null(ODR o, const char *str)
+{
+ return nmem_strdup_null(o->mem, str);
+}
+
char *odr_strdupn(ODR o, const char *str, size_t n)
{
return nmem_strdupn(o->mem, str, n);
int *odr_intdup(ODR o, int v)
{
- if (o && !o->mem)
- o->mem = nmem_create();
return nmem_intdup(o->mem, v);
}
int odr_total(ODR o)
{
- return o->mem ? nmem_total(o->mem) : 0;
+ return nmem_total(o->mem);
}
Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, int sz)
{
Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct));
- p->buf = odr_malloc(o, sz);
+ p->buf = (unsigned char *) odr_malloc(o, sz);
memcpy(p->buf, buf, sz);
p->size = sz;
p->len = sz;
{
int togrow;
- if (!b->can_grow)
+ if (!b->op->can_grow)
return -1;
if (!b->size)
togrow = 1024;