From 2aa1b1e3025157f738a49552f9d37ef0a3d53939 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Thu, 13 Oct 2005 13:24:22 +0000 Subject: [PATCH] proper reallocation algorithm --- org.glite.jp.index/src/soap_ops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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]; -- 1.8.2.3