< prev index next >

src/hotspot/share/utilities/ostream.cpp

Print this page
rev 58767 : 8242485: Null _file checking in fileStream::flush()


 548     ::fseek(_file, pos, SEEK_SET);
 549   }
 550   return size;
 551 }
 552 
 553 char* fileStream::readln(char *data, int count ) {
 554   char * ret = ::fgets(data, count, _file);
 555   //Get rid of annoying \n char
 556   data[::strlen(data)-1] = '\0';
 557   return ret;
 558 }
 559 
 560 fileStream::~fileStream() {
 561   if (_file != NULL) {
 562     if (_need_close) fclose(_file);
 563     _file      = NULL;
 564   }
 565 }
 566 
 567 void fileStream::flush() {

 568   fflush(_file);

 569 }
 570 
 571 void fdStream::write(const char* s, size_t len) {
 572   if (_fd != -1) {
 573     // Make an unused local variable to avoid warning from gcc compiler.
 574     size_t count = ::write(_fd, s, (int)len);
 575   }
 576   update_position(s, len);
 577 }
 578 
 579 defaultStream* defaultStream::instance = NULL;
 580 int defaultStream::_output_fd = 1;
 581 int defaultStream::_error_fd  = 2;
 582 FILE* defaultStream::_output_stream = stdout;
 583 FILE* defaultStream::_error_stream  = stderr;
 584 
 585 #define LOG_MAJOR_VERSION 160
 586 #define LOG_MINOR_VERSION 1
 587 
 588 void defaultStream::init() {




 548     ::fseek(_file, pos, SEEK_SET);
 549   }
 550   return size;
 551 }
 552 
 553 char* fileStream::readln(char *data, int count ) {
 554   char * ret = ::fgets(data, count, _file);
 555   //Get rid of annoying \n char
 556   data[::strlen(data)-1] = '\0';
 557   return ret;
 558 }
 559 
 560 fileStream::~fileStream() {
 561   if (_file != NULL) {
 562     if (_need_close) fclose(_file);
 563     _file      = NULL;
 564   }
 565 }
 566 
 567 void fileStream::flush() {
 568   if (_file != NULL) {
 569     fflush(_file);
 570   }
 571 }
 572 
 573 void fdStream::write(const char* s, size_t len) {
 574   if (_fd != -1) {
 575     // Make an unused local variable to avoid warning from gcc compiler.
 576     size_t count = ::write(_fd, s, (int)len);
 577   }
 578   update_position(s, len);
 579 }
 580 
 581 defaultStream* defaultStream::instance = NULL;
 582 int defaultStream::_output_fd = 1;
 583 int defaultStream::_error_fd  = 2;
 584 FILE* defaultStream::_output_stream = stdout;
 585 FILE* defaultStream::_error_stream  = stderr;
 586 
 587 #define LOG_MAJOR_VERSION 160
 588 #define LOG_MINOR_VERSION 1
 589 
 590 void defaultStream::init() {


< prev index next >