gnustep-dev
[Top][All Lists]
Advanced

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

Re: Cannot emulate hash


From: David Chisnall
Subject: Re: Cannot emulate hash
Date: Tue, 9 Aug 2011 09:49:26 +0100

Thanks,

The problem was that the existing code was setting the mutation pointer to 
value of the version field.  The fast enumeration loop dereferences this 
pointer immediately calling the fast enumeration method and then once in each 
inner loop iteration, to check that it gets the same value both times.  

By setting this pointer to the version, the loop was doing *(unsigned long*)3.  
As you can imagine, this didn't go well.  It should have been (and now is) set 
to the address of the version.

The code was also a bit weird.  We have a generic function for implementing 
fast enumeration on anything using GSIMap, but both NSConcreteMapTable and 
NSConcreteHashTable were rolling their own.  I've deleted both and replaced 
them with the 2-line version, so there are fewer places for bugs to hide.

David

On 9 Aug 2011, at 08:51, Bluna Ratimonkey wrote:

> Hi,
> This code crash, it works fine with array, what could be wrong? I
> can't backtrace for anything, I am using clang version 3.0 (trunk
> 137038)
> 
> NSHashTable* a = [NSHashTable new];
> 
> [a addObject:@"a"];
> [a addObject:@"b"];
> [a addObject:@"c"];
> 
> for (id obj in a)
> {
> }
> 
> 
> -- 
> /* Join Bluna Ratimonkey (漫画家) and build the real future for GNUstep ! */
>    [@"http://mus3.sourceforge.net"; setNeedsYourHelps:YES!!];
> 
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev


-- Sent from my Difference Engine






reply via email to

[Prev in Thread] Current Thread [Next in Thread]