【发布时间】:2013-11-04 11:00:35
【问题描述】:
我在一段 C 代码上运行 splint,它给了我以下语句:
jmptable.c:34:5: Implicitly only storage vm->jumptable (type struct
jumptable_entry **) not released before assignment:
vm->jumptable = (struct jumptable_entry **)calloc(vm->jumptable_size + 1,
sizeof(struct jumptable_entry *))
A memory leak has been detected. Only-qualified storage is not released
before the last reference to it is lost. (Use -mustfreeonly to inhibit
warning)
我知道夹板希望我在使用 calloc 分配内存之前先 free 分配内存,但由于这是在应用程序的初始化过程中,我应该担心吗?
编辑:这是 vm->jumptable 的初始化方式
vm->jumptable = (struct jumptable_entry**) calloc(vm->jumptable_size + 1,
sizeof(struct jumptable_entry*));
【问题讨论】:
-
我们需要在这里查看更多代码才能真正了解发生了什么。
-
需要说明
vm->jumptable是如何初始化的。