Browse Source

Increased size of myDataBuffer by one in a different location.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@71 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 9 years ago
parent
commit
2ef5fa98e1
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      configuration.cpp

+ 3
- 1
configuration.cpp View File

ifstream CFGFile(FileName.c_str()); // Open the file. ifstream CFGFile(FileName.c_str()); // Open the file.
CFGFile.seekg(0,ios::end); // Seek to the end CFGFile.seekg(0,ios::end); // Seek to the end
myBufferSize = CFGFile.tellg(); // to find out what size it is. myBufferSize = CFGFile.tellg(); // to find out what size it is.
myDataBuffer = new char[myBufferSize]; // Make a new buffer the right size.
myDataBuffer = new char[myBufferSize + 1]; // Make a new buffer the right size,
// including null byte at end.
CFGFile.seekg(0,ios::beg); // Seek to the beginning and CFGFile.seekg(0,ios::beg); // Seek to the beginning and
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer.
myDataBuffer[myBufferSize] = '\0'; // Null-terminate.
if(CFGFile.bad()) { // If the read failed, we're unusable! if(CFGFile.bad()) { // If the read failed, we're unusable!
delete[] myDataBuffer; // Delete the buffer delete[] myDataBuffer; // Delete the buffer
myDataBuffer = NULL; // and Null it's pointer. myDataBuffer = NULL; // and Null it's pointer.

Loading…
Cancel
Save