Changeset 4884


Ignore:
Timestamp:
Nov 30, 2015, 8:45:35 AM (3 years ago)
Author:
cameron
Message:

Empty file fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/icgrep1.0/icgrep-devel/icgrep-1.00a/do_grep.cpp

    r4794 r4884  
    177177    }
    178178    mFileSize = infile_sb.st_size;
    179     mFileBuffer = (char *) mmap(NULL, mFileSize, PROT_READ, MAP_PRIVATE, fdSrc, 0);
    180     if (mFileBuffer == MAP_FAILED) {
    181         if (errno ==  ENOMEM) {
    182             std::cerr << "Error:  mmap of " << infilename << " failed: out of memory\n";
    183         }
    184         else {
    185             std::cerr << "Error: mmap of " << infilename << " failed with errno " << errno << ". Skipped.\n";
    186         }
    187         return;
    188     }
     179    if (mFileSize == 0) {
     180        mFileBuffer = nullptr;
     181    }
     182    else {
     183        mFileBuffer = (char *) mmap(NULL, mFileSize, PROT_READ, MAP_PRIVATE, fdSrc, 0);
     184        if (mFileBuffer == MAP_FAILED) {
     185            if (errno ==  ENOMEM) {
     186                std::cerr << "Error:  mmap of " << infilename << " failed: out of memory\n";
     187            }
     188            else {
     189                std::cerr << "Error: mmap of " << infilename << " failed with errno " << errno << ". Skipped.\n";
     190            }
     191            return;
     192        }
     193        }
    189194    char * buffer_ptr;
    190195    size_t segment = 0;
Note: See TracChangeset for help on using the changeset viewer.