Re: Who is releasing my CFAllocator?
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.