2

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;                                                                       
}            

これは宿題ですが、この質問は宿題に直接関係する必要はありません。これは副子の質問です。

4

1 に答える 1

1

フレッシュストレージという用語は、プログラムに割り当てられたばかりのメモリバッファを指します。

「フレッシュストレージが解放されていません」という警告は、バッファが解放に失敗した同じ関数によって割り当てられた場合の「ストレージのみが解放されていない」という特殊なケースです。

于 2012-01-30T17:38:13.543 に答える