Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does -getLineStart:end:contentsEnd:forRange work ?



Am 29.06.2006 um 16:14 schrieb email@hidden:
       unsigned* startIndex=47;
	unsigned* lineEndIndex=48;
	unsigned* contentsEndIndex=49;

Those three don't make sense. You're declaring variables to hold addresses and then assign arbitrary numbers to those addresses. So, you're asking getLineStart:... to change memory addresses 47, 48 and 49, which are very likely somewhere deep in system memory and will cause your app to get killed before it can screw up the system. You have to declare some actual unsigned variables and point to them using the address-of operator.


If this wasn't just a typo caused by lack of caffeine, you may want to read some articles on memory management. It just so happens that I wrote one:

	http://www.zathras.de/angelweb/howmemorymanagementworks.htm

And there's more info on memory in my "Masters of the Void" C course (still in progress, but what's there is at http://www.zathras.de/ angelweb/masters-of-the-void.htm) in particular in chapter 5 (http:// www.zathras.de/angelweb/masters-of-the-void-book5.htm).

Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >How does -getLineStart:end:contentsEnd:forRange work ? (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.