Re #691: fixed memory allocation bugs (Boris)
o terrainSplitOb(): too much space allocated for vertex, norm and snorm arrays in new object. o in createSingleTexChannelArrays() too much space for texture array is allocated o assumption was that it contains 3 * num surfaces entries o but it's actually only numvertice * 2 entries git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4936 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 11d5639f3783e89acaab31237ccb061c491d04b3 Former-commit-id: 9e158c8ea04cb9107b6000c8f56c880e8b87dd73
This commit is contained in:
parent
d8fdb3e1c2
commit
f47de46c40
1 changed files with 8 additions and 12 deletions
|
@ -300,10 +300,8 @@ void clearSavedInVertexArrayEntry(ob_t * ob, int vertidx)
|
||||||
|
|
||||||
void createSingleTexChannelArrays(ob_t * destob, ob_t * srcob, int channel)
|
void createSingleTexChannelArrays(ob_t * destob, ob_t * srcob, int channel)
|
||||||
{
|
{
|
||||||
int numvert = srcob->numsurf * 3;
|
int size_va = srcob->numsurf * 3 * sizeof(tcoord_t);
|
||||||
|
int size_ta = 2 * srcob->numvertice * sizeof(double);
|
||||||
int size_va = numvert * sizeof(tcoord_t);
|
|
||||||
int size_ta = 2 * numvert * sizeof(double);
|
|
||||||
|
|
||||||
tcoord_t * va = (tcoord_t *) malloc(size_va);
|
tcoord_t * va = (tcoord_t *) malloc(size_va);
|
||||||
double* ta = (double *) malloc(size_ta);
|
double* ta = (double *) malloc(size_ta);
|
||||||
|
@ -684,17 +682,15 @@ int terrainSplitOb(ob_t **object)
|
||||||
tob->vertexarray[curNewSurf * 3 + 2].indice = m1;
|
tob->vertexarray[curNewSurf * 3 + 2].indice = m1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numNewPts = curNewPtIdx;
|
|
||||||
|
|
||||||
free(storedPtIdxArr);
|
free(storedPtIdxArr);
|
||||||
|
|
||||||
tob->norm = (point_t*) malloc(sizeof(point_t) * numtri * 3);
|
int numNewPts = curNewPtIdx;
|
||||||
tob->snorm = (point_t*) malloc(sizeof(point_t) * numtri * 3);
|
|
||||||
tob->vertex = (point_t*) malloc(sizeof(point_t) * numtri * 3);
|
|
||||||
memset(tob->snorm, 0, sizeof(point_t) * numtri * 3);
|
|
||||||
memset(tob->norm, 0, sizeof(point_t) * numtri * 3);
|
|
||||||
|
|
||||||
tob->textarray = (double *) malloc(sizeof(tcoord_t) * numtri * 2);
|
tob->norm = (point_t*) calloc(numNewPts, sizeof(point_t));
|
||||||
|
tob->snorm = (point_t*) calloc(numNewPts, sizeof(point_t));
|
||||||
|
tob->vertex = (point_t*) calloc(numNewPts, sizeof(point_t));
|
||||||
|
|
||||||
|
tob->textarray = (double *) calloc(numtri * 2, sizeof(tcoord_t));
|
||||||
tob->attrSurf = (*object)->attrSurf;
|
tob->attrSurf = (*object)->attrSurf;
|
||||||
tob->attrMat = (*object)->attrMat;
|
tob->attrMat = (*object)->attrMat;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue