X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=data1%2Fd1_grs.c;h=8daa6a3276f8332471497190d02d766995bddb9e;hp=d818603d48783152f69e50651e525a2f94476a12;hb=e2e073b5c947e996304ed7d577497af5e9a879ee;hpb=6a0f9234f945bc4956e2bcef75f715661a9eba9a diff --git a/data1/d1_grs.c b/data1/d1_grs.c index d818603..8daa6a3 100644 --- a/data1/d1_grs.c +++ b/data1/d1_grs.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1994-2009 Index Data + Copyright (C) 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 @@ -19,6 +19,9 @@ 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 @@ -78,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) { @@ -106,7 +107,7 @@ static int traverse_triples(data1_node *n, int level, Z_ElementMetaData *m, ODR o) { data1_node *c; - + for (c = n->child; c; c = c->next) if (c->which == DATA1N_data && level) { @@ -192,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: @@ -235,7 +235,7 @@ static int is_empty_data (data1_node *n) || n->u.data.what == DATA1I_xmltext)) { int i = n->u.data.len; - + while (i > 0 && d1_isspace(n->u.data.data[i-1])) i--; if (i == 0) @@ -295,22 +295,20 @@ 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 { char *tagstr; - if (n->which == DATA1N_tag) + if (n->which == DATA1N_tag) tagstr = n->u.tag.tag; /* tag at node */ - else if (tag) + else if (tag) tagstr = tag->value.string; /* no take from well-known */ else return 0;