Re: crashing in CFStringInitInlineBuffer
Re: crashing in CFStringInitInlineBuffer
- Subject: Re: crashing in CFStringInitInlineBuffer
- From: Jonathan Stocks <email@hidden>
- Date: Wed, 29 May 2002 10:15:19 -0700
Hi Jim,
I may not be the best person to answer this but it appears that you are
passing a null (or at least it is not initialized) pointer to
CFStringInitInlineBuffer(...). What you might want to try is creating
your CFStringInlineBuffer as:
CFStringInlineBuffer buff;
Then, when you call CFStringInitInlineBuffer(...) as:
CFStringInitInlineBuffer( myCFString, &buff, myRange );
With the line:
CFStringInlineBuffer *buff;
you are creating an "uninitialized" pointer. This can cause a bad
access error. CFStringInitInlineBuffer(...) doesn't seem to allocate
you buffer for you, so you will probably have to do it ahead of time.
Someone else can probably elaborate this for you further, but hopefully
it can get you going for now. :)
Thanks,
Jon
On Wednesday, May 29, 2002, at 09:41 AM, Jim Winetke wrote:
I'm pretty new to both C and Cocoa, and I think I'm good and stuck on a
crashing problem with CFStringInlineBuffer. Here's my sample method:
- (IBAction)testBuffer:(id)sender
{
CFStringRef myCFString = CFSTR("string me up");
CFStringInlineBuffer *buff;
CFRange myRange;
UniChar littleCharacter;
CFIndex idx;
myRange = CFRangeMake(0, 2); //just a test
CFStringInitInlineBuffer(myCFString, buff, myRange);
// other stuff here if I can get past the initializer
}
It's crashing in the buffer initializer (from CFString.h):
CF_INLINE void CFStringInitInlineBuffer(CFStringRef str,
CFStringInlineBuffer *buf,
CFRange range) {
buf->theString = str;
buf->rangeToBuffer = range;
buf->directBuffer = CFStringGetCharactersPtr(str);
buf->bufferedRangeStart = buf->bufferedRangeEnd = 0;
}
In the first line, "theString = str", with EXC_BAD_ACCESS. I can't
figure
it out. At first I think I was casting improperly from an NSString to a
CFStringRef, but now I'm just using the CFSTR macro. CFShowStr gives me
good info on myCFString, so I presume it's a valid CFString object.
Any help would be appreciated. I'd also love to hear if there's any
sample
code out there for CFStringInlineBuffer -- I couldn't find any at
Apple's
site.
Jim
PS: what's up with "CFRangeMake"? It's documented as "CFMakeRange",
which
I presumed off the bat as an analogue to NSMakeRange, and I burned up a
bunch of time trying to figure out the "implicit declaration" build
errors.
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.