GTf_z 2020-08-02 09:35 采纳率: 0%
浏览 59

free()时出错,为何如此?

void Transmatrix(matrix sample)

{
int psample, ptemp, col;
int* cnum, * cpos;
node temp;

temp = (node)calloc(sample->num, sizeof(struct Node));
cnum = (int*)calloc(sample->r + 1, sizeof(int));
cpos = (int*)calloc(sample->r + 1, sizeof(int));

for (psample = 0; psample < sample->num; psample++) {
    cnum[sample->front[psample].r]++;
}

for (col = 1; col <= sample->r; col++) {
    cpos[col] = cpos[col - 1] + cnum[col - 1];
}

for (psample = 0; psample < sample->num; psample++) {
    col = sample->front[psample].r;
    ptemp = cpos[col];

    temp[ptemp].data = sample->front[psample].data;
    temp[ptemp].l = sample->front[psample].r;
    temp[ptemp].r = sample->front[psample].l;

    cpos[ptemp]++;
}

free(sample->front);
sample->front = temp;

free(cpos);    //出错
free(cnum);

}
图片说明

  • 写回答

2条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 vue使用gojs,需求在link中的虚线上添加方向箭头
  • ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
  • ¥15 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红