At 8:16 PM +0400 7/28/05, Igor Garnov wrote:
>On Jul 28, 2005, at 19:49, Jim Correia wrote:
>
>>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.
>
>Hmm...
>
>here are the lines from Aliases.h:
>
>struct AliasRecord {
> OSType userType; /* appl stored type like creator type */
> unsigned short aliasSize; /* alias record size in bytes, for appl usage */
>};
>typedef struct AliasRecord AliasRecord;
>typedef AliasRecord * AliasPtr;
>typedef AliasPtr * AliasHandle;
>
>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?
>And after that, wouldn't a call like: 'ResolveAlias( 0, &pItemAlias, ... ) be legal?
>
>Otherwise, what can I do to create a valid alias handle with the data I store internally?
AliasHandle aliasHandle = (AliasHandle)::NewHandle( sizeof( AliasRecord ) );
to fiddle:
if( aliasHandle )
(*aliasHandle)->userType = 'FOO ';
later dispose with ::DisposeHandle( (Handle)aliasRecord );
Please read the docs on the Memory Manager as posted by Marshall...
alex
>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
_______________________________________________
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