X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fodr_mem.c;h=c970f6b6baee2a431ed29b3595545ef08d192f88;hp=42f8d873c89a4527e8a3c41c2b39bd9fac811029;hb=8377081b9917f820ae91f17e24743c84ef0cfc4d;hpb=28b489257f5f5b9263659a83a4df0ad2c61428c4 diff --git a/src/odr_mem.c b/src/odr_mem.c index 42f8d87..c970f6b 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2008 Index Data * See the file LICENSE for details. - * - * $Id: odr_mem.c,v 1.7 2006-02-19 18:33:09 adam Exp $ */ /** * \file odr_mem.c @@ -25,24 +23,25 @@ NMEM odr_extract_mem(ODR o) { 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); @@ -50,20 +49,18 @@ char *odr_strdupn(ODR o, const char *str, size_t 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; @@ -77,7 +74,7 @@ int odr_grow_block(ODR b, int min_bytes) { int togrow; - if (!b->can_grow) + if (!b->op->can_grow) return -1; if (!b->size) togrow = 1024;