• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Correct use of CFArraySortValues context parameter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct use of CFArraySortValues context parameter


  • Subject: Re: Correct use of CFArraySortValues context parameter
  • From: Markus Spoettl <email@hidden>
  • Date: Sat, 07 Dec 2013 15:55:03 +0100

On 12/7/13 3:35 PM, Ken Thomases wrote:
Can anyone tell me if the latter use of CFArraySortValues() is correct?

It is.  Your analysis is correct.

It doesn't feel right to cast an int option to (void *) but the
documentation simply doesn't say it will pass on a dereferenced value.

The docs for CFArraySortValues() describes the context parameter as "[a]
pointer-sized program-defined value".  It is declared as a pointer only to
guarantee that it's large enough to hold a pointer even on architectures
where a pointer is larger than, say, an int.  But semantically, it's just a
"value".  It may have been better for Apple to have used uintptr_t.

The fact that the leak went away tells me I'm on the right track.

Well, I can't explain why passing the pointer to the context variable would
have caused a leak.  In theory, CFStringCompare() would simply have
interpreted it as a option bit mask with an arbitrary variety of options set.
I wouldn't expect any such options to cause a leak.

But you're right that the original call was incorrect.

Thanks Ken for the quick confirmation!

In that case, a word of warning to all AquaticPrime users - that's where this code comes from. The function you're looking for is APCreateDictionaryForLicenseData().

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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


References: 
 >Correct use of CFArraySortValues context parameter (From: Markus Spoettl <email@hidden>)
 >Re: Correct use of CFArraySortValues context parameter (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Correct use of CFArraySortValues context parameter
  • Next by Date: Re: Threaded drawing
  • Previous by thread: Re: Correct use of CFArraySortValues context parameter
  • Next by thread: What are the contents of NSPasteboardTypeFont?
  • Index(es):
    • Date
    • Thread