什么是“保鲜存储”在夹板?
我在 Splint 文档中搜索了“新鲜存储”,并发现了它的提及,但没有正式的定义。其他修饰符,例如 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;
}
这是一个家庭作业,但是这个问题与家庭作业没有直接关系。这是一个夹板问题。
I have searched the Splint documentation for "fresh storage", and have found mention of it, but no formal definition. The other modifiers, like null or only, I understand and am putting to use. I'm just not sure what fresh storage is.
The situation is this:
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;
}
This is a homework assignment, but this question doesn't have to do directly with the homework. This is a splint question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
术语新鲜存储指的是刚刚为您的程序分配的内存缓冲区。
警告“新鲜存储未释放”只是“仅存储未释放”的特殊情况,当缓冲区由无法释放它的同一函数分配时。
The term fresh storage refers to a memory buffer which has been just allocated for your program.
The warning "Fresh storage not released" is just a special case of "Only storage not released", when the buffer is allocated by the same function which fails to release it.