X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=odr%2Fodr_mem.c;h=2ec348a7368949a34ba1dd81256b38f877ea6c3a;hp=d5d31938a3f8f59d34cb29b5274dbd3bf536e29a;hb=c71d717ada2a9ef730d527f161eb5ba9aa641a9f;hpb=19af2bd8dfd21731cc978beccd1346133d614c67 diff --git a/odr/odr_mem.c b/odr/odr_mem.c index d5d3193..2ec348a 100644 --- a/odr/odr_mem.c +++ b/odr/odr_mem.c @@ -1,73 +1,15 @@ /* - * Copyright (c) 1995-2000, Index Data + * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Log: odr_mem.c,v $ - * Revision 1.18 2000-02-29 13:44:55 adam - * Check for config.h (currently not generated). - * - * Revision 1.17 2000/01/31 13:15:21 adam - * Removed uses of assert(3). Cleanup of ODR. CCL parser update so - * that some characters are not surrounded by spaces in resulting term. - * ILL-code updates. - * - * Revision 1.16 1999/11/30 13:47:11 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.15 1999/03/31 11:18:25 adam - * Implemented odr_strdup. Added Reference ID to backend server API. - * - * Revision 1.14 1998/07/20 12:38:15 adam - * More LOG_DEBUG-diagnostics. - * - * Revision 1.13 1998/02/11 11:53:34 adam - * Changed code so that it compiles as C++. - * - * Revision 1.12 1995/11/08 17:41:33 quinn - * Smallish. - * - * Revision 1.11 1995/11/01 13:54:43 quinn - * Minor adjustments - * - * Revision 1.10 1995/10/25 16:58:19 quinn - * Stupid bug in odr_malloc - * - * Revision 1.9 1995/10/13 16:08:08 quinn - * Added OID utility - * - * Revision 1.8 1995/09/29 17:12:24 quinn - * Smallish - * - * Revision 1.7 1995/09/27 15:02:59 quinn - * Modified function heads & prototypes. - * - * Revision 1.6 1995/08/21 09:10:41 quinn - * Smallish fixes to suppport new formats. - * - * Revision 1.5 1995/05/16 08:50:55 quinn - * License, documentation, and memory fixes - * - * Revision 1.4 1995/05/15 11:56:09 quinn - * More work on memory management. - * - * Revision 1.3 1995/04/18 08:15:21 quinn - * Added dynamic memory allocation on encoding (whew). Code is now somewhat - * neater. We'll make the same change for decoding one day. - * - * Revision 1.2 1995/03/17 10:17:52 quinn - * Added memory management. - * - * Revision 1.1 1995/03/14 10:27:40 quinn - * Modified makefile to use common lib - * Beginning to add memory management to odr - * + * $Id: odr_mem.c,v 1.23 2003-03-18 13:34:35 adam Exp $ */ #if HAVE_CONFIG_H #include #endif #include -#include +#include "odr-priv.h" #include /* ------------------------ NIBBLE MEMORY ---------------------- */ @@ -95,6 +37,16 @@ char *odr_strdup(ODR o, const char *str) return nmem_strdup(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) +{ + return nmem_intdup(o->mem, v); +} + int odr_total(ODR o) { return o->mem ? nmem_total(o->mem) : 0; @@ -131,7 +83,7 @@ int odr_write(ODR o, unsigned char *buf, int bytes) { if (o->pos + bytes >= o->size && odr_grow_block(o, bytes)) { - o->error = OSPACE; + odr_seterror(o, OSPACE, 40); return -1; } memcpy(o->buf + o->pos, buf, bytes); @@ -149,7 +101,7 @@ int odr_seek(ODR o, int whence, int offset) offset += o->top; if (offset > o->size && odr_grow_block(o, offset - o->size)) { - o->error = OSPACE; + odr_seterror(o, OSPACE, 41); return -1; } o->pos = offset;