== 11260 ==写入大小4无效
== 11260 ==在0x402872:b2_createPair(在/ home / david / Documents / programming / 366 terminal / mainout
== 11260 == by 0x402BE9:b2_populateBigBucket(在/ home / david / Documents / programming / 366 terminal / mainout中)
== 11260 == by 0x401993:doTads_b2(tads.c:82)
== 11260 == by 0x400E82:main(main.c:159)
== 11260 ==地址0x51d0318在大小为8的块之后为0字节
== 11260 ==在0x4C28F9F:malloc(vg_replace_malloc.c:236)
== 11260 == by 0x402866:b2_createPair(在/ home / david / Documents / programming / 366 terminal / mainout)
== 11260 == by 0x402BE9:b2_populateBigBucket(在/ home / david / Documents / programming / 366 terminal / mainout中)
== 11260 == by 0x401993:doTads_b2(tads.c:82)
== 11260 == by 0x400E82:main(main.c:159)
我不习惯这个 - 通常它会给我前两行的行号。
另外 - 如果你想帮助我 - 我无法理解为什么它不喜欢这个malloc -
pair2* b2_createPair(int nodeFrom, int nodeTo, int distance)
{
pair2* p = malloc(sizeof(pair2*));
if (p==NULL)
{
printf("Malloc was NULL\n"); fflush(stdout);
}
else
{
p->distance = distance;
p->nodeFrom = nodeFrom;
p->nodeTo = nodeTo;
}
return p ;
}
(好的 - 请注意p-> nodeTo = nodeFrom错误 - 但这不会影响结果。
结构看起来像
struct pair2_t
{
int nodeFrom;
int nodeTo;
int distance;
struct pair2_t *previous;
struct pair2_t *next;
};
typedef struct pair2_t pair2;
答案 0 :(得分:0)
尝试:
pair2 *p = malloc(sizeof(pair2));
...
请务必在某个时候free()
。