【 以下文字转载自 Linux 讨论区 】
发信人: ouyadi (可乐会捂帮帮众), 信区: Linux
标 题: Valgrind报uninitialized value was created by a heap allocation
发信站: BBS 未名空间站 (Sat Feb 19 12:11:20 2011, 美东)
程序运行正常,可是在测memery leak的时候报上面那个错,具体错误消息如下:
==25663== Conditional jump or move depends on uninitialised value(s)
==25663== at 0x400C9F: add_edge (graph.c:59)
==25663== by 0x40071A: main (main.c:13)
==25663== Uninitialised value was created by a heap allocation
==25663== at 0x4A0515D: malloc (vg_replace_malloc.c:195)
==25663== by 0x400A80: add_vertex (graph.c:22)
==25663== by 0x400DF8: add_edge (graph.c:84)
==25663== by 0x40071A: main (main.c:13)
我的程序用链接表构建一个无向图来解决TSP的.
graph.c:22
for(adj_v=(*vp)->adj_list; adj_v->next!=NULL; adj_v=adj_v->next);
adj_v->next = (adj_vertex_t *)malloc(sizeof(adj_vertex_t));
adj_v=adj_v->next;
adj_v->edge_weight=weight;
我这个该怎么初始化新alloc的memery space呢?因为我马上要加新的节点信息到这个
地方了,看起来应该没问题啊?C语言不太好,请大牛指教