From: Bill S. <bi...@in...> - 2010-03-21 22:46:52
|
>> Hi Bill, >> >> many thanks for your efforts! >> >> Before doing such a major change, we should define some simple >> examples as test cases. >> >> Attached you will find something, much more is needed. >> >> Regards >> >> Holger >Hi all, > > I tried Holgers three testcases here on a debian linux machine, > and got segmentation faults. > They are caused by freeing something which hasn't been allocated. > I've attached a fix. > >Regards > >Robert Hi Robert, Good catch. I like the fix except for the elimination for the for loop. I think pedagogically it is more elegant but to each their own. Both statements are equivalent and will be compiled into the same binary. In some cases, the use of the for loop will allow the compiler to unroll easier but it this case it should be exactly the same. - for (entry_p = nghash_enumerateRE( htable_p,&iter ) ; - entry_p ; - entry_p = nghash_enumerateRE( htable_p,&iter)) + while (NULL != (entry_p = nghash_enumerateRE(htable_p, &iter))) -- Best Regards, ----------------------- Bill Swartz InternetCad.com, Inc. 10880 Cassandra Way Dallas, TX 75228-2493 email : Bil...@in... fax : 972-613-1127 http : www.internetcad.com (70.104.27.21) : www2.internetcad.com (204.0.6.171) |