On Mon, Dec 14, 2009 at 3:25 PM, Jacob Burbach <jmburb...@gmail.com> wrote: > Not sure what you meant about gdb generating code to cause it, I get > the same error when run outside of gdb. Assembly of the function > below, if you need something else let me know.
I meant gcc, sorry :) Thanks for the listing. Looks like the number is loaded by the code before the IS_NUM check, but I suspect it is for passing to the equal function (which got inlined - confusing, eh?). If it were c++ code we could change it to a const reference ... as it is, I think we'll have to try the const pointer route as per attached patch :( -- Csaba/Jester
diff --git a/simgear/nasal/hash.c b/simgear/nasal/hash.c index 1efe8fb..0aebc15 100644 --- a/simgear/nasal/hash.c +++ b/simgear/nasal/hash.c @@ -62,12 +62,12 @@ static unsigned int refhash(naRef key) } } -static int equal(naRef a, naRef b) +static int equal(const naRef* a, const naRef* b) { - if(IS_NUM(a)) return a.num == b.num; - if(PTR(a).obj == PTR(b).obj) return 1; - if(naStr_len(a) != naStr_len(b)) return 0; - return memcmp(naStr_data(a), naStr_data(b), naStr_len(a)) == 0; + if(IS_NUM(*a)) return a->num == b->num; + if(PTR(*a).obj == PTR(*b).obj) return 1; + if(naStr_len(*a) != naStr_len(*b)) return 0; + return memcmp(naStr_data(*a), naStr_data(*b), naStr_len(*a)) == 0; } /* Returns the index of a cell that either contains a matching key, or @@ -76,7 +76,7 @@ static int findcell(struct HashRec *hr, naRef key, unsigned int hash) { int i, mask = POW2(hr->lgsz+1)-1, step = (2*hash+1) & mask; for(i=HBITS(hr,hash); TAB(hr)[i] != ENT_EMPTY; i=(i+step)&mask) - if(TAB(hr)[i] != ENT_DELETED && equal(key, ENTS(hr)[TAB(hr)[i]].key)) + if(TAB(hr)[i] != ENT_DELETED && equal(&key, &ENTS(hr)[TAB(hr)[i]].key)) break; return i; }
------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev
_______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel