Re: Optimize causes an error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's what I'd do... first grade debugging.  Add in these diagnostic lines:

void PPDict1::getData(int position, int size, unsigned char *buffer) {
  int fsize = getDataLength();
  if ((position + size) > fsize) {
    memset(buffer, 0, size);
    return;
  }
  int tinx=(position-getIndexOffset())+size;

// Which of these things has the unexpected value?
  assert(tinx >= 0);
  assert(getIndexSize() >= 0);
  assert(getIndexOffset() >= 0);
  bool const haveMoreTinx = tinx < getIndexSize();
  bool const isPtrNonZero = indexPTR_ != 0;
  std::cerr << tinx << " := (" << position << " - "
    << getIndexOffset() << ") + " << size;
  std::cerr << haveMoreTinx << " := " << tinx << " < " << getIndexSize()
    << '\n';
  std::cerr << isPtrNonZero << " := " << indexPtr_ << " != 0\n";
  std::cerr << haveMoreTinx << " && " << isPtrNonZero << '\n';

  if((tinx<getIndexSize())&&(indexPTR_!=0)){
    inxcount_++;
    void * tPtr=indexPTR_+position-getIndexOffset();
    memcpy(buffer, tPtr, size);
  }else{
    dictStream_.seekg(position);
    dictStream_.read((char *)buffer, size);
    profcount_++;
  }
}

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux