summaryrefslogtreecommitdiffstats
path: root/src/map/if/ifMan.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-11-28 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2006-11-28 08:01:00 -0800
commit44d220d28fa2ee56cb539e03684f021731814f17 (patch)
tree97ece1e77fa8fff2283c62fb9253424e566e7fba /src/map/if/ifMan.c
parent6ad22b4d3b0446652919d95b15fefb374bddfac0 (diff)
downloadabc-44d220d28fa2ee56cb539e03684f021731814f17.tar.gz
abc-44d220d28fa2ee56cb539e03684f021731814f17.tar.bz2
abc-44d220d28fa2ee56cb539e03684f021731814f17.zip
Version abc61128
Diffstat (limited to 'src/map/if/ifMan.c')
-rw-r--r--src/map/if/ifMan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c
index 616c5cf6..bc13c6f0 100644
--- a/src/map/if/ifMan.c
+++ b/src/map/if/ifMan.c
@@ -97,7 +97,7 @@ void If_ManStop( If_Man_t * p )
FREE( p->pPars->pTimesReq );
// free temporary cut memory
pTemp = p->ppCuts[0];
- for ( i = 1; i < p->pPars->nCutsMax * p->pPars->nCutsMax; i++ )
+ for ( i = 1; i < 1 + p->pPars->nCutsMax * p->pPars->nCutsMax; i++ )
if ( pTemp > p->ppCuts[i] )
pTemp = p->ppCuts[i];
free( pTemp );
@@ -228,14 +228,18 @@ If_Cut_t ** If_ManSetupCuts( If_Man_t * p )
{
If_Cut_t ** pCutStore;
int * pArrays, nCutSize, nCutsTotal, i;
- nCutsTotal = p->pPars->nCutsMax * p->pPars->nCutsMax;
+ // decide how many cuts to alloc
+ nCutsTotal = 1 + p->pPars->nCutsMax * p->pPars->nCutsMax;
+ // figure out the cut size
nCutSize = sizeof(If_Cut_t) + sizeof(int) * p->pPars->nLutSize;
+ // allocate and clean space for cuts
pCutStore = (If_Cut_t **)ALLOC( If_Cut_t *, (nCutsTotal + 1) );
memset( pCutStore, 0, sizeof(If_Cut_t *) * (nCutsTotal + 1) );
pCutStore[0] = (If_Cut_t *)ALLOC( char, nCutSize * nCutsTotal );
memset( pCutStore[0], 0, nCutSize * nCutsTotal );
for ( i = 1; i < nCutsTotal; i++ )
pCutStore[i] = (If_Cut_t *)((char *)pCutStore[0] + sizeof(If_Cut_t) * i);
+ // assign room for cut leaves
pArrays = (int *)((char *)pCutStore[0] + sizeof(If_Cut_t) * nCutsTotal);
for ( i = 0; i < nCutsTotal; i++ )
pCutStore[i]->pLeaves = pArrays + i * p->pPars->nLutSize;