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: ResolveAlias leads to crash



Hello

thanks everyone and sorry for being stubborn with my belief that &pointer = handle. I missed the keyword stating that handle is something more than just a pointer to a pointer. No I seem to get the point (-:

Please keep replies on the list. I'm happy to help, but only if the
help is going to benefit the community at large.

On Jul 28, 2005, at 11:44 AM, Igor Garnov wrote:

Yeah, sure it's the pointer to actual data. pItemAlias is declared as
UInt8*, so it should be OK.

No, it is not.

You can't take the address of a pointer that was allocated, cast it to
a handle, and pass it off to an API that expects a handle.


What happens when the alias manager does GetHandleSize(alias) or
SetHandleSize(alias). It goes boom if you passed it a pointer to a
pointer that wasn't a handle.

If you are doing this, don't, and your problem will go away.
I declare a variable like this: UInt8* pItemAlias. Then I allocate
memory like this: pItemAlias = NewPtr( aliasSize ); (aliasSize contains
the actual alias size), and copy the actual alias data into this
allocated memory.


So I could cast my pointer to AliasPtr, couldn't I?

No, that's what Jim just said. You can't do this. A Mac "Handle" is more
than just a pointer to a pointer. It's a pointer to a pointer with some
"extras" that a simple pointer to a pointer won't have.


And after that, wouldn't a call like: 'ResolveAlias( 0, &pItemAlias,
... ) be legal?

No, not at all. You need to do some reading up on the Memory Manager. We're
talking basic Mac memory concepts here that go back to 1984.

I definitely will.

Otherwise, what can I do to create a valid alias handle with the data I
store internally?

Well, gee, maybe NewHandle(), which actually returns a handle?

What data are you storing? The only way to get the data you can use in an
AliasHandle is to use one of the NewAlias APIs. Have you stored data from an
AliasHandle in your preferences or some such thing?

Exactly, I store the alias data in my preferences. Later I am trying to recover the initial file by giving the stored data to ResolveAlias function.


Regards,
Igor

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

This email sent to email@hidden
References: 
 >Re: ResolveAlias leads to crash (From: Laurence Harris <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.