Hi all,
Hoping you can help with a free() problem I'm having. I have the following struct:
Code:
typedef struct fillline{
// to be used in an array. one filline correponds to a scanline, ie a Yvalue
int X1; // Left most Xcoord
int X2; // rightmost Xcoord
} fillline;
which is then allocated in an array as follows:
Code:
fillline *pointarray = (struct fillline *)malloc(sizeof(fillline)*Dy);
for (int i = 0; i< Dy; i++)
{
pointarray[i].X1 = SCREENX + SCREENY; //initialise to be a big number
pointarray[i].X2 =-1; // initialise to be a small number
}
after i've done stuff with my array (passed pointarray to a function and filled up the X1 and X2 values etc I try this:
which when running in debug mode in VC6 tells me that a user breakpoint has been called - this apparently happens when you try to free memory that hasn't been malloc'd, but as far as I can tell I've malloc'd pointarray fine.
Any ideas people? I've also tried keeping a copy of pointarray and freeing that, in case pointarray had changed value, but I think I saw somewhere that free() is actually working by value so that wouldn't have made much of a difference anyway...