Gmorning SO-
valgrind says:
==9735== 24,976 bytes in 446 blocks are definitely lost in loss record 9 of 9
==9735== at 0x100012362: malloc (vg_replace_malloc.c:266)
==9735== by 0x1000016F2: interpolate (in ./a.out)
==9735== by 0x100000CFA: main (in ./a.out)
Yikes. Here's my interpolate function:
void interpolate(PDouble* evaluated, int doubleCount){
int i, j, k;
int boxCount = 0;
int frameCount = 0;
for(i=0; i<doubleCount; i++){
boxCount = evaluated[i]->first->numBoxes;
frameCount = evaluated[i]->gap;
evaluated[i]->changeMatrix = (int***)malloc(boxCount*sizeof(int**));
for(j=0; j < boxCount; j++){
evaluated[i]->changeMatrix[j] = (int **)malloc(ATTR * sizeof(int*));
for(k=0; k < ATTR; k++){
evaluated[i]->changeMatrix[j][k] = (int*)malloc(sizeof(int)*frameCount);
if(evaluated[i]->differenceMatrix[j][k] > 200 ||
evaluated[i]->differenceMatrix[j][k] < -200){
generateRotationSequence(evaluated[i]->changeMatrix[j][k],
evaluated[i]->first->boxes[j]->o,
evaluated[i]->second->boxes[j]->o,
frameCount);
}
else{
evaluated[i]->changeMatrix[j][k] = (int*)malloc(sizeof(int)*frameCount);
generateSequence(evaluated[i]->changeMatrix[j][k],
evaluated[i]->differenceMatrix[j][k], frameCount);
}
}
}
}
}
But I have the C functions that free all the pointers for PDoubles. I can provide the code if needed, but is there anything glaring about this that would make it leak, or make pointers dangle?
Edit: Realized I was using a strange term in description. Also this time im adding my destructors
void killDouble(PDouble marked){
int i, j, k;
int gap = marked->gap;
for(i=0; i < marked->first->numBoxes; i++){
for(j=0; j < ATTR; j++){
free(marked->changeMatrix[i][j]);
}
free(marked->changeMatrix[i]);
free(marked->differenceMatrix[i]);
}
for(i=0; i < gap; i++){
killFrame(marked->intFrames[i]);
}
killFrame(marked->first);
killFrame(marked->second);
free(marked->changeMatrix);
free(marked->differenceMatrix);
free(marked->intFrames);
free(marked);
}