This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Optimize causes an error.


This Method works just find and dandy if I use no optimization. If I
use O1, O2, or O3  the if statement below the comment is always
returning true!
I have initialized all the member variables and still if I compile
with O1 it just doesn't work.
BTW this code is to cache the index of the file to speed up a binary
search. It was tacked on when we found that the flash file system was
too slow.

And now for a simple question. How the heck to I find out how much
free memory I have in c?
None of the programmers at my office know because we haven't needed to
check for free memory for many years.
Thanks for any help.


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; // WITH O1 this like is always returning true! 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_++; } }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]