extern void DwarfFini( dw_client client ) /****************************************/ { int i; int status; char *out_fname; FILE *out_file; if( !CompFlags.emit_browser_info ) return; DWEndCompileUnit( client ); DWFini( client ); // close after writing for( i = 0 ; i < DW_DEBUG_MAX ; i++ ) { DwioCloseOutputFile( dw_sections[i].file ); } out_fname = IoSuppOutFileName( OFT_MBR ); out_file = SrcFileFOpen( out_fname, SFO_WRITE_BINARY ); if( out_file == NULL ) { puts( strerror( errno ) ); puts( out_fname ); CFatal( "dwarf: unable to open file for writing" ); } // concatenate files if( createBrowseFile( out_file, &dw_sections[DW_DEBUG_ABBREV], &dw_sections[DW_DEBUG_INFO], &dw_sections[DW_DEBUG_REF], &dw_sections[DW_DEBUG_LINE], &dw_sections[DW_DEBUG_MACINFO] ) ) { puts( strerror( errno ) ); CFatal( "dwarf: error in merging browse files" ); } status = SrcFileFClose( out_file ); if( status ) { puts( strerror( errno ) ); puts( out_fname ); CFatal( "dwarf: unable to close file" ); } // delete for( i = 0 ; i < DW_DEBUG_MAX ; i++ ) { DwioFreeFile( dw_sections[i].file ); } DwioFini(); }
boolean IoSuppCloseFile( // CLOSE FILE IF OPENED FILE **file_ptr ) // - addr( file pointer ) { boolean retn; // - return: TRUE ==> was open BUF_ALLOC* ba; // - current allocated buffer if( *file_ptr == NULL ) { retn = FALSE; } else { RingIterBegSafe( buffers, ba ) { if( *file_ptr == ba->buffer ) { freeBuffer( ba ); break; } } RingIterEndSafe( ba ); SrcFileFClose( *file_ptr ); *file_ptr = NULL; retn = TRUE; } return( retn ); }