Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions OpenCTM-1.0.3/lib/compressMG1.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ int _ctmCompressMesh_MG1(_CTMcontext * self)
CTMuint * indices;
_CTMfloatmap * map;
CTMuint i;
size_t indexElemCount;

#ifdef __DEBUG_
printf("COMPRESSION METHOD: MG1\n");
#endif

// Perpare (sort) indices
indices = (CTMuint *) malloc(sizeof(CTMuint) * self->mTriangleCount * 3);
indexElemCount = (size_t) self->mTriangleCount * 3;
indices = (CTMuint *) calloc(indexElemCount, sizeof(CTMuint));
if(!indices)
{
self->mError = CTM_OUT_OF_MEMORY;
Expand Down Expand Up @@ -185,7 +187,6 @@ int _ctmCompressMesh_MG1(_CTMcontext * self)
_ctmStreamWrite(self, (void *) "VERT", 4);
if(!_ctmStreamWritePackedFloats(self, self->mVertices, self->mVertexCount * 3, 1))
{
free((void *) indices);
return CTM_FALSE;
}

Expand Down Expand Up @@ -241,9 +242,11 @@ int _ctmUncompressMesh_MG1(_CTMcontext * self)
CTMuint * indices;
_CTMfloatmap * map;
CTMuint i;
size_t indexElemCount;

// Allocate memory for the indices
indices = (CTMuint *) malloc(sizeof(CTMuint) * self->mTriangleCount * 3);
indexElemCount = (size_t) self->mTriangleCount * 3;
indices = (CTMuint *) calloc(indexElemCount, sizeof(CTMuint));
if(!indices)
{
self->mError = CTM_OUT_OF_MEMORY;
Expand Down