c++ - _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) 错误

标签 c++ arrays delete-operator

我在下面代码的最后一行遇到错误“_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)”:

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;

为什么会出现这样的错误?由于我已将这些指针值复制到 file->cam1cam2ThreeDPoints,因此我应该能够删除 tempSpace

最佳答案

tempSpace++; 更改指针。您需要记住最初分配的指针,以便用它调用 delete

关于c++ - _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34722064/

相关文章:

c++ - 使用 constexpr C 字符串作为编译器错误消息

arrays - 有没有办法在 Swift 中打破数组的 reduce 函数?

php - 填充数组中缺失的元素

c++ - 删除指向 const (T const*) 的指针

c++ - 如何从监视列表中隐藏一些类公共(public)属性?

c++ - 如何使用虚函数对基类进行抽象?

c++ - 删除 C++ 中的每个指针作为指向数组的指针是否安全?

c++ - 为 std::shared_ptr 指定一个删除器,它适用于特定类型或其派生类型的所有对象

c++ - 我在哪里可以看到 ATLTRACE 输出?

C++ 去掉前导零