Valgrind 告诉我,内存中存在泄漏,我曾尝试 free() 它,但我认为它没有正确完成。有任何想法吗?谢谢你。
0x4C27D4E 处的 free()/delete/delete[]/realloc() 无效:free (vg_replace_malloc.c:427)
by 0x400C00: main (main.c:149)
地址 0x51ba138 是大小为 8 的块分配后的 0 字节
在 0x4C28BED: malloc (vg_replace_malloc.c:263) by 0x400B0E: main (main.c:119)
堆摘要:退出时使用:1 个块中的 2 个字节总堆使用:5 个分配,5 个释放,14 个分配的字节
1 个块中的 2 个字节在丢失记录 1 of 1 中肯定丢失
在 0x4C28BED:malloc (vg_replace_malloc.c:263)
由 0x40084F: strdup (main.c:19)
通过 0x4009C4:置换(main.c:83)
由 0x400B9C: main (main.c:138)
char *strdup (const char *s)
{
char *d = malloc (strlen (s) + 1); // Space for length plus null //line 19
if (d …Run Code Online (Sandbox Code Playgroud)