Re: Who is releasing my CFAllocator?
Re: Who is releasing my CFAllocator?
- Subject: Re: Who is releasing my CFAllocator?
- From: Chris Kane <email@hidden>
- Date: Tue, 6 Aug 2002 10:46:15 -0700
On Sunday, August 4, 2002, at 03:34 PM, Nat! wrote:
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.
The documentation is wrong, or at least, misleading. The reallocate
callback, I suppose, is free to return NULL if passed a NULL ptr, but
that's really moot because CFAllocator will not call the reallocate()
callback if the ptr to CFAllocatorReallocate() is NULL -- the
allocate() callback is called instead. The same sort of thing applies
to the newsize parameter -- CFAllocator won't call the reallocate()
callback if the newsize is 0 -- it will either (1) return NULL, if the
ptr is NULL [matching the allowed behavior of malloc(0)] or (2)
deallocate the ptr if it is non-NULL.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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.