X-Git-Url: http://git.indexdata.com/?p=yazpp-moved-to-github.git;a=blobdiff_plain;f=src%2Fyaz-z-assoc.cpp;h=cd7046bd919f8454f1f5eda58df3820afebe12a5;hp=eb6f9bf0d6b91b627ea22e2139461cf40aa106c9;hb=82d0b6ce2accdbe9987d0b8b4e6e818514455e22;hpb=cd57d092689576508ec75cec0b837cbee83cd141 diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index eb6f9bf..cd7046b 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -1,5 +1,5 @@ /* This file is part of the yazpp toolkit. - * Copyright (C) 1998-2012 Index Data and Mike Taylor + * Copyright (C) Index Data * See the file LICENSE for details. */ @@ -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,11 @@ 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, +#if YAZ_VERSIONL < 0x50000 + (unsigned char *) +#endif + str, strlen(str)); return id; }