From: Miloš Mulač Date: Thu, 13 Oct 2005 13:24:22 +0000 (+0000) Subject: proper reallocation algorithm X-Git-Tag: glite-jp-client_R_1_0_0~66 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=2aa1b1e3025157f738a49552f9d37ef0a3d53939;p=jra1mw.git proper reallocation algorithm --- diff --git a/org.glite.jp.index/src/soap_ops.c b/org.glite.jp.index/src/soap_ops.c index 7e56343..f3bff91 100644 --- a/org.glite.jp.index/src/soap_ops.c +++ b/org.glite.jp.index/src/soap_ops.c @@ -140,7 +140,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__UpdateJobs( static int checkIndexedConditions(glite_jpis_context_t ctx, struct _jpelem__QueryJobs *in) { - char **indexed_attrs; + char **indexed_attrs = NULL; int i, j, k, ret; @@ -155,7 +155,7 @@ static int checkIndexedConditions(glite_jpis_context_t ctx, struct _jpelem__Quer while (glite_jp_db_fetch(ctx->select_info_attrs_indexed) == 0) { if (!(i % INDEXED_STRIDE)) { indexed_attrs = realloc(indexed_attrs, - ((i / INDEXED_STRIDE) * INDEXED_STRIDE + 1) + ((i / INDEXED_STRIDE + 1) * INDEXED_STRIDE) * sizeof(*indexed_attrs)); } indexed_attrs[i++] = strdup(ctx->param_indexed); @@ -288,12 +288,12 @@ static int get_jobids(struct soap *soap, glite_jpis_context_t ctx, struct _jpele while ( (ret = glite_jp_db_fetchrow(stmt, res)) > 0 ) { if (!(i % JOBIDS_STRIDE)) { jids = realloc(jids, - ((i / JOBIDS_STRIDE) * JOBIDS_STRIDE + 2) + ((i / JOBIDS_STRIDE + 1) * JOBIDS_STRIDE + 1) * sizeof(*jids)); } if (!(i % JOBIDS_STRIDE)) { pss = realloc(pss, - ((i / JOBIDS_STRIDE) * JOBIDS_STRIDE + 2) + ((i / JOBIDS_STRIDE + 1) * JOBIDS_STRIDE + 1) * sizeof(*pss)); } jids[i] = res[0];