oops, that was a bit sloppy. Also added a missing free

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1169 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2012-03-17 02:23:03 +00:00
parent 1b5b24155d
commit 99cd253ea3

View File

@ -695,15 +695,18 @@ static void fghCube( GLdouble dSize, GLboolean useWireMode )
/* Need to build new vertex list containing vertices for cube of different size */ /* Need to build new vertex list containing vertices for cube of different size */
GLdouble *vertices = malloc(CUBE_VERT_ELEM_PER_OBJ * sizeof(GLdouble)); GLdouble *vertices = malloc(CUBE_VERT_ELEM_PER_OBJ * sizeof(GLdouble));
/* Bail out if memory allocation fails, fgError never returns */ /* Bail out if memory allocation fails, fgError never returns */
if (!(*vertices)) if (!vertices)
{ {
free(*vertices); free(vertices);
fgError("Failed to allocate memory in fghCube"); fgError("Failed to allocate memory in fghCube");
} }
for (i=0; i<CUBE_VERT_ELEM_PER_OBJ; i++) for (i=0; i<CUBE_VERT_ELEM_PER_OBJ; i++)
vertices[i] = dSize*cube_verts[i]; vertices[i] = dSize*cube_verts[i];
fghDrawGeometry(GL_TRIANGLES,vertices ,cube_norms,cube_edgeFlags,CUBE_VERT_PER_OBJ_TRI,useWireMode); fghDrawGeometry(GL_TRIANGLES,vertices ,cube_norms,cube_edgeFlags,CUBE_VERT_PER_OBJ_TRI,useWireMode);
/* cleanup allocated memory */
free(vertices);
} }
else else
fghDrawGeometry(GL_TRIANGLES,cube_verts,cube_norms,cube_edgeFlags,CUBE_VERT_PER_OBJ_TRI,useWireMode); fghDrawGeometry(GL_TRIANGLES,cube_verts,cube_norms,cube_edgeFlags,CUBE_VERT_PER_OBJ_TRI,useWireMode);
@ -728,10 +731,10 @@ static void fghSierpinskiSponge ( int numLevels, GLdouble offset[3], GLdouble sc
vertices = malloc(numVert*3 * sizeof(GLdouble)); vertices = malloc(numVert*3 * sizeof(GLdouble));
normals = malloc(numVert*3 * sizeof(GLdouble)); normals = malloc(numVert*3 * sizeof(GLdouble));
/* Bail out if memory allocation fails, fgError never returns */ /* Bail out if memory allocation fails, fgError never returns */
if (!(*vertices) || !(*normals)) if (!vertices || !normals)
{ {
free(*vertices); free(vertices);
free(*normals); free(normals);
fgError("Failed to allocate memory in fghSierpinskiSponge"); fgError("Failed to allocate memory in fghSierpinskiSponge");
} }