From 32a5aaaa9a78f9ee028090496a85c3aa8526ea27 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 11 Sep 2013 10:26:42 +0200 Subject: [PATCH] Use odr_create_Odr_oct and make yazpp work with both YAZ 4 and YAZ 5. --- src/yaz-z-assoc.cpp | 20 +++++++------------- zlint/zlint.cpp | 8 ++------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index 22247c2..1663757 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -205,16 +205,14 @@ void Z_Assoc::transfer_referenceId(Z_APDU *from, Z_APDU *to) { Z_ReferenceId **id_from = get_referenceIdP(from); Z_ReferenceId **id_to = get_referenceIdP(to); - if (id_from && *id_from && id_to) + if (id_to) { - *id_to = (Z_ReferenceId*) odr_malloc(m_p->odr_out, sizeof(**id_to)); - (*id_to)->size = (*id_to)->len = (*id_from)->len; - (*id_to)->buf = (unsigned char*) - odr_malloc(m_p->odr_out, (*id_to)->len); - memcpy((*id_to)->buf, (*id_from)->buf, (*id_to)->len); + if (id_from && *id_from) + *id_to = odr_create_Odr_oct(m_p->odr_out, (*id_from)->buf, + (*id_from)->len); + else + *id_to = 0; } - else if (id_to) - *id_to = 0; } int Z_Assoc::send_Z_PDU(Z_APDU *apdu, int *plen) @@ -453,11 +451,7 @@ Z_ReferenceId* Z_Assoc::getRefID(char* str) Z_ReferenceId* id = NULL; if (str) - { - id = (Z_ReferenceId*) odr_malloc(m_p->odr_out, sizeof(*id)); - id->size = id->len = strlen(str); - id->buf = (unsigned char *) str; - } + id = odr_create_Odr_oct(m_p->odr_out, str, strlen(str)); return id; } diff --git a/zlint/zlint.cpp b/zlint/zlint.cpp index 88aa73f..b8b8d59 100644 --- a/zlint/zlint.cpp +++ b/zlint/zlint.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -149,12 +150,7 @@ IPDU_Observer *Zlint::sessionNotify( Z_ReferenceId *Zlint::mk_refid(const char *buf, int len) { - Z_ReferenceId *id = - (Z_ReferenceId *) odr_malloc(odr_encode(), sizeof(*id)); - id->size = id->len = len; - id->buf = (unsigned char*) odr_malloc(odr_encode(), len); - memcpy(id->buf, buf, len); - return id; + return odr_create_Odr_oct(odr_encode(), buf, len); } int Zlint::initResponseGetVersion(Z_InitResponse *init) -- 1.7.10.4