• 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: Who is releasing my CFAllocator?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Who is releasing my CFAllocator?


  • Subject: Re: Who is releasing my CFAllocator?
  • From: Nat! <email@hidden>
  • Date: Mon, 5 Aug 2002 00:34:47 +0200

At the risk on getting on your nerves :) one more question to CFAllocator. The documentation for the AllocatorContext callbacks (file:///Developer/Documentation/CoreFoundation/BaseServices/Base_Services_ConcTask/
index.html)
sez:

void * (*reallocate)(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info);

Change the size of the block of memory pointed to by ptr to the size specified by newsize and return the pointer to the larger block of memory. Return NULL on any reallocation failure, leaving the old block of memory untouched. Also return NULL immediately if any of the following conditions apply:

 The ptr parameter is NULL .
*********************************
 The newsize parameter is not greater than zero.


Now good ol' realloc happily accepted realloc( NULL, 256) and it was the same as malloc( 256). The example code in AllocatorExample.c

static void *countingRealloc(void *oPtr, CFIndex size, CFOptionFlags hint, void *info)
{
...
if (ptr) {
...
} else {
ptr = malloc(size + sizeof(int) * 6);
}

also happily handles NULL like realloc used to. So who to trust ? Common sense and the example code or the documentation ?

Ciao
Nat!

Jedenfalls sind zehn Fehlstarts hintereinander [E. Fuchs]
ein sehr interessanter Beweis
fuer unsere Theorie
von der natuerlichen Ueberlegenheit des Dezimalsystems
_______________________________________________
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.

  • Follow-Ups:
    • Re: Who is releasing my CFAllocator?
      • From: Chris Kane <email@hidden>
    • Re: Who is releasing my CFAllocator?
      • From: Nat! <email@hidden>
  • Prev by Date: Re: Omni Frameworks build problems
  • Next by Date: "std::basic_string" link undefined syms?
  • Previous by thread: Re: Who is releasing my CFAllocator?
  • Next by thread: Re: Who is releasing my CFAllocator?
  • Index(es):
    • Date
    • Thread