X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=data1%2Fd1_grs.c;h=fe816b4f5ca14136fd5ff2bd298bd7e73b78b97f;hp=e295a25dc2928503ba5d1712d57136eee025ab0c;hb=e2d9fea369fcf6f0e8927b7b53b69d0bc4f9a50a;hpb=6c9fcd3b5d3108702fa1ffc92dab4ab6060f9a19 diff --git a/data1/d1_grs.c b/data1/d1_grs.c index e295a25..fe816b4 100644 --- a/data1/d1_grs.c +++ b/data1/d1_grs.c @@ -1,8 +1,5 @@ -/* $Id: d1_grs.c,v 1.7 2005-01-15 19:38:18 adam Exp $ - Copyright (C) 1995-2005 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -15,13 +12,16 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ /* converts data1 tree to GRS-1 record */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -81,10 +81,8 @@ static Z_Variant *make_variant(data1_node *n, int num, ODR o) assert(p->which == DATA1N_variant); t = v->triples[num] = (Z_Triple *)odr_malloc(o, sizeof(*t)); t->variantSetId = 0; - t->zclass = (int *)odr_malloc(o, sizeof(int)); - *t->zclass = p->u.variant.type->zclass->zclass; - t->type = (int *)odr_malloc(o, sizeof(int)); - *t->type = p->u.variant.type->type; + t->zclass = odr_intdup(o, p->u.variant.type->zclass->zclass); + t->type = odr_intdup(o, p->u.variant.type->type); switch (p->u.variant.type->datatype) { @@ -195,8 +193,7 @@ static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n, { case DATA1I_num: res->which = Z_ElementData_numeric; - res->u.numeric = (int *)odr_malloc(o, sizeof(int)); - *res->u.numeric = atoi_n (cp, toget); + res->u.numeric = odr_intdup(o, atoi_n(cp, toget)); *len += 4; break; case DATA1I_text: @@ -298,14 +295,12 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, return 0; } - res->tagType = (int *)odr_malloc(o, sizeof(int)); - *res->tagType = (tag && tag->tagset) ? tag->tagset->type : 3; + res->tagType = odr_intdup(o, (tag && tag->tagset) ? tag->tagset->type : 3); res->tagValue = (Z_StringOrNumeric *)odr_malloc(o, sizeof(Z_StringOrNumeric)); if (tag && tag->which == DATA1T_numeric) { res->tagValue->which = Z_StringOrNumeric_numeric; - res->tagValue->u.numeric = (int *)odr_malloc(o, sizeof(int)); - *res->tagValue->u.numeric = tag->value.numeric; + res->tagValue->u.numeric = odr_intdup(o, tag->value.numeric); } else { @@ -403,3 +398,12 @@ Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n, } return data1_nodetogr_r(dh, n, select, o, len, wellknown_tag); } +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +