X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fodr_mem.c;h=33e2bfadb28f4832eda27901f63ca440aee8ac6d;hb=612ac7d30003582e44d4184c830eee7f1a1a0443;hp=555c4435c0e0f92aaaf384ee57e5cce67b936fb8;hpb=6278ee39573b69b59333a876c52671d0ebbca320;p=yaz-moved-to-github.git diff --git a/src/odr_mem.c b/src/odr_mem.c index 555c443..33e2bfa 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2009 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ /** @@ -27,7 +27,7 @@ NMEM odr_extract_mem(ODR o) return r; } -void *odr_malloc(ODR o, int size) +void *odr_malloc(ODR o, size_t size) { return nmem_malloc(o->mem, size); } @@ -57,17 +57,16 @@ Odr_bool *odr_booldup(ODR o, Odr_bool v) return nmem_booldup(o->mem, v); } -int odr_total(ODR o) +size_t odr_total(ODR o) { return nmem_total(o->mem); } -Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, int sz) +Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz) { Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct)); - p->buf = (unsigned char *) odr_malloc(o, sz); + p->buf = (char *) odr_malloc(o, sz); memcpy(p->buf, buf, sz); - p->size = sz; p->len = sz; return p; } @@ -88,15 +87,14 @@ int odr_grow_block(ODR b, int min_bytes) if (togrow < min_bytes) togrow = min_bytes; if (b->size && !(b->buf = - (unsigned char *) xrealloc(b->buf, b->size += togrow))) + (char *) xrealloc(b->buf, b->size += togrow))) abort(); - else if (!b->size && !(b->buf = (unsigned char *) - xmalloc(b->size = togrow))) + else if (!b->size && !(b->buf = (char *) xmalloc(b->size = togrow))) abort(); return 0; } -int odr_write(ODR o, unsigned char *buf, int bytes) +int odr_write(ODR o, const char *buf, int bytes) { if (o->pos + bytes >= o->size && odr_grow_block(o, bytes)) { @@ -125,21 +123,26 @@ int odr_seek(ODR o, int whence, int offset) return 0; } -Odr_int odr_atoi(const char *s) +Odr_int odr_strtol(const char *nptr, char **endptr, int base) { #if NMEM_64 - char *endptr; #if WIN32 - return _strtoui64(s, &endptr, 10); + return _strtoui64(nptr, endptr, base); #else - return strtoll(s, &endptr, 10); + return strtoll(nptr, endptr, base); #endif #else - return atoi(s); + return strtol(nptr, endptr, base); #endif } +Odr_int odr_atoi(const char *s) +{ + char *endptr; + return odr_strtol(s, &endptr, 10); +} + /* * Local variables: * c-basic-offset: 4