gpt4 book ai didi

c - Splint 中的 "Fresh Storage"是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 23:55:25 25 4
gpt4 key购买 nike

我在 Splint 文档中搜索了“fresh storage”,发现有提及,但没有正式定义。其他修饰符,如 null 或 only,我理解并正在使用。我只是不确定新鲜存储是什么。

情况是这样的:

void output_system_information(unsigned int frequency, unsigned int duration) { 

unsigned int intervals = duration/frequency;

/* here I allocate some storage */
System * my_system = malloc(sizeof(System));

SystemInfo* current, * total;

if (my_system == NULL) {
fprintf(stderr, "%s\n", "Aborting: failed malloc in output_system_informatioin");
exit(EXIT_FAILURE);
}

/* and here I initialize is in that function */
init_system(my_system);
total = tally_system_info(frequency, duration, my_system);
current = my_system->get_system_info();

/* Here I've removed a ton of print-line statements so that you don't have to see them */

/* then the members and the struct get freed in this here dtor */
delete_system(my_system);
free(current);
free(total);

return;
}

这是一项家庭作业,但这个问题不一定与家庭作业直接相关。这是一个夹板问题。

最佳答案

术语新鲜存储指的是刚刚分配给您的程序的内存缓冲区。

警告 “Fresh storage not released” 只是 “Only storage not released” 的一个特例,当缓冲区由同一函数分配时失败释放它。

关于c - Splint 中的 "Fresh Storage"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9058659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com