What is "Fresh Storage" in Splint?

843 views Asked by At

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.

1

There are 1 answers

3
Guillermo Calvo On BEST ANSWER

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.