Re: CFDictionary callback on PPC vs Intel
Re: CFDictionary callback on PPC vs Intel
- Subject: Re: CFDictionary callback on PPC vs Intel
- From: William Squires <email@hidden>
- Date: Sun, 17 Feb 2008 11:07:25 -0600
On Feb 17, 2008, at 9:51 AM, Derrek Leute wrote:
Hello all,
The included semi-pseudo code works on my Macbook Pro (core duo
32-bit) and doesn't work on my powermac g5.
Macbook Pro behavior: Gets or creates the mref and adds it to the
args_set.
Powermac G5 behavior: The CFNumberRef mref never changes after the
first run no matter what the CFStringRef smref value is. The strange
thing is it does make it inside the if statement from the
CFDictionaryGetValueIfPresent (according to debugging) but the mref
pointer never changes. Thus, the args_set only ever has one pointer
value in it no matter the data available.
The following is a stripped down version that probably doesn't compile
(missing file pointer and such) as I copied and pasted only the
relevant parts:
/* Begin code snippet */
CFMutableDictionaryRef args = CFDictionaryCreateMutable
(NULL,0,&kCFCopyStringDictionaryKeyCallBacks,NULL);
Huh? How can you pass a reference to a CONST
(kCFCopyStringDictionaryKeyCallBacks)? I thought a CONST was just a
compiler replacement at compile-time, and doesn't actually have any
storage. Or is this not a CONST?
__strong CFMutableSetRef args_set = CFSetCreateMutable(NULL,0,NULL);
while (fgets(line, LINE_MAX, fp) != NULL && int < 26000) {
int = int +1;
char *m = strtok(line,sep);
int im = atoi(m);
CFNumberRef mref;
CFStringRef smref = CFStringCreateWithCString(NULL, m,
kCFStringEncodingUTF8);
CFStringRef srref = CFStringCreateWithCString(NULL, r,
kCFStringEncodingUTF8);
if (!CFDictionaryGetValueIfPresent(args, smref, (const void **)
&mref)) {
CFNumberRef nmref = CFMakeCollectable(CFNumberCreate(NULL,
kCFNumberSInt16Type, &im));
CFDictionaryAddValue(args, smref, nmref);
CFDictionaryGetValueIfPresent(args, smref, (const void **)&mref);
}
CFRelease(smref);
CFSetAddValue(args_set, mref);
}
/* End code snippet */
In case you are wondering why I want to do this: The file I'm reading
in can be many gigabytes in size. It is a csv representation of a
database in which each row uses a few different values over and over.
I basically need unique pointers to each value. In most cases the
value itself is not needed at all. Doing this allowed me to turn the
text of a value in a csv into an existing pointer to an in memory
object, and if it doesn't exist, create it.
Any ideas why this would work on intel and not on ppc?
Or, better yet, anyone have a better way to do this? I'm new at this
and would appreciate any suggestions code clarifications and memory
management help. I am using garbage collection.
Thank you!
--Derrek
http://www.allofzero.com/~dleute/
email@hidden (preferred contact)
home: (802) 347-1573
cell: (516) 528-4619
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40satx.rr.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden