Reputation: 105
I encoutered an error "_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)" at the last line of the code below:
pixelCoorindateAndThreePoint* tempSpace = new pixelCoorindateAndThreePoint[possibleMaxSize];
while (sscanf(temp, "%f %f", &cam1x, &cam1y)){
location = (int)(file->length*cam1y + cam1x);
file->cam1cam2ThreeDPoints[(int)(file->length*cam1y + cam1x)] = new pixelCoorindateAndThreePoint;
sscanf(temp, "%*f %*f %f %f %f %f %f \n",
&(tempSpace->PixelCoordinateCam2.x),
&(tempSpace->PixelCoordinateCam2.y),
&(tempSpace->threePoints.x),
&(tempSpace->threePoints.y),
&(tempSpace->threePoints.z));
file->cam1cam2ThreeDPoints[location] = tempSpace;
tempSpace++;
temp = strtok(NULL, "\n");
}
delete[] tempSpace;
Why I get such an error? Since I have copy those pointer value to file->cam1cam2ThreeDPoints
, I should be able to delete tempSpace
.
Upvotes: 0
Views: 116
Reputation: 1
tempSpace++;
changes the pointer. You need to remember the originally allocated pointer for calling delete
with it.
Upvotes: 3