From: Jiří Filipovič Date: Thu, 15 Mar 2007 13:01:50 +0000 (+0000) Subject: fix the bug in merging attributes X-Git-Tag: glite-lb-server-bones_R_2_2_4_1~10 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=9a6a54586af6227c72382e039449bcf768b98344;p=jra1mw.git fix the bug in merging attributes --- diff --git a/org.glite.jp.primary/src/attrs.c b/org.glite.jp.primary/src/attrs.c index d2f5a1d..5c1873a 100644 --- a/org.glite.jp.primary/src/attrs.c +++ b/org.glite.jp.primary/src/attrs.c @@ -68,6 +68,7 @@ static int merge_attrvals(glite_jp_attrval_t **out,int nout,const glite_jp_attrv for (nin=0; in[nin].name; nin++); *out = realloc(*out,(nout+nin+1) * sizeof **out); memcpy(*out + nout,in,(nin+1) * sizeof **out); + memset(*out + nout+nin, 0, sizeof **out); return nout+nin; } @@ -104,7 +105,7 @@ void process_files(glite_jp_context_t ctx, const char *job, glite_jp_attrval_t** glite_jpps_get_attrs(glite_jp_context_t ctx,const char *job,char **attr,int nattr,glite_jp_attrval_t **attrs_out) { - glite_jp_attrval_t *meta = NULL,*out = NULL,*tag_out; + glite_jp_attrval_t *meta = NULL,*out = NULL,*tag_out = NULL; char const **other = NULL; int i,j,nmeta,nother,err = 0,nout = 0; @@ -138,10 +139,7 @@ glite_jpps_get_attrs(glite_jp_context_t ctx,const char *job,char **attr,int natt void* beh; for (i = 0; i < nother; i++){ if (! glite_jppsbe_read_tag(ctx, job, other[i], &tag_out)) { - for (j=0; tag_out[j].name; j++); - out = realloc(out,(nout+j) * sizeof *out); - memcpy(out+nout,tag_out,j * sizeof *out); - nout += j; + nout = merge_attrvals(&out, nout, tag_out); free(tag_out); tag_out = NULL; } for (j = 0; known_namespaces[j].namespace; j++) {