From 28b489257f5f5b9263659a83a4df0ad2c61428c4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 19 Feb 2006 18:33:08 +0000 Subject: [PATCH] Implemented utility odr_create_Odr_oct to create Odr_oct struct with content --- include/yaz/odr.h | 4 +++- src/odr_mem.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/yaz/odr.h b/include/yaz/odr.h index 421f44a..9d746fc 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr.h,v 1.21 2005-06-25 15:46:03 adam Exp $ + * $Id: odr.h,v 1.22 2006-02-19 18:33:08 adam Exp $ */ /** @@ -192,6 +192,8 @@ YAZ_EXPORT void *odr_malloc(ODR o, int size); YAZ_EXPORT char *odr_strdup(ODR o, const char *str); YAZ_EXPORT char *odr_strdupn(ODR o, const char *str, size_t n); YAZ_EXPORT int *odr_intdup(ODR o, int v); +YAZ_EXPORT Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, + int sz); YAZ_EXPORT NMEM odr_extract_mem(ODR o); YAZ_EXPORT Odr_null *odr_nullval(void); #define odr_release_mem(m) nmem_destroy(m) diff --git a/src/odr_mem.c b/src/odr_mem.c index 2e7e286..42f8d87 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: odr_mem.c,v 1.6 2005-08-11 14:21:55 adam Exp $ + * $Id: odr_mem.c,v 1.7 2006-02-19 18:33:09 adam Exp $ */ /** * \file odr_mem.c @@ -60,6 +60,16 @@ int odr_total(ODR o) return o->mem ? nmem_total(o->mem) : 0; } +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); + memcpy(p->buf, buf, sz); + p->size = sz; + p->len = sz; + return p; +} + /* ---------- memory management for data encoding ----------*/ -- 1.7.10.4