From 240de66672a5b12b1a0deebc18508719dc780828 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 1 May 2013 14:09:39 +0200 Subject: [PATCH] Add odr_write2 (improved odr_write) Like odr_write but takes const char*, instead of unsigned char* . --- include/yaz/odr.h | 1 + src/odr_mem.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/yaz/odr.h b/include/yaz/odr.h index 9c997a3..20f245b 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -285,6 +285,7 @@ YAZ_EXPORT Odr_oid *odr_oiddup(ODR odr, const Odr_oid *o); YAZ_EXPORT Odr_oid *odr_oiddup_nmem(NMEM nmem, const Odr_oid *o); YAZ_EXPORT int odr_grow_block(ODR b, int min_bytes); YAZ_EXPORT int odr_write(ODR o, unsigned char *buf, int bytes); +YAZ_EXPORT int odr_write2(ODR o, const char *buf, int bytes); YAZ_EXPORT int odr_seek(ODR o, int whence, int offset); YAZ_EXPORT int odr_dumpBER(FILE *f, const char *buf, int len); YAZ_EXPORT void odr_choice_bias(ODR o, int what); diff --git a/src/odr_mem.c b/src/odr_mem.c index cfd082b..4309d3d 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -96,7 +96,7 @@ int odr_grow_block(ODR b, int min_bytes) return 0; } -int odr_write(ODR o, unsigned char *buf, int bytes) +int odr_write2(ODR o, const char *buf, int bytes) { if (o->pos + bytes >= o->size && odr_grow_block(o, bytes)) { @@ -110,6 +110,11 @@ int odr_write(ODR o, unsigned char *buf, int bytes) return 0; } +int odr_write(ODR o, unsigned char *buf, int bytes) +{ + return odr_write2(o, (char *) buf, bytes); +} + int odr_seek(ODR o, int whence, int offset) { if (whence == ODR_S_CUR) -- 1.7.10.4