使用 C 中的简单链表实现,我如何告诉 Splint 我正在转移所有权data
?
typedef struct {
void* data;
/*@null@*/ void* next;
} list;
static /*@null@*/ list* new_list(/*@notnull@*/ void* data)
{
list* l;
l = malloc(sizeof(list));
if (l == NULL)
return NULL;
l->next = NULL;
l->data = data;
return l;
}
我收到此错误消息:
Implicitly temp storage data assigned to implicitly
only: list->data = data
Temp storage (associated with a formal parameter) is transferred to a
non-temporary reference. The storage may be released or new aliases created.
(Use -temptrans to inhibit warning)
我想告诉 Splint 释放的责任data
已转移到列表数据结构中。