× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Fri, Feb 15, 2008 at 9:13 AM, Lim Hock-Chai
<Lim.Hock-Chai@xxxxxxxxxxxxxxx> wrote:
is there a reason to ever use dealloc without the (n) extender?
--

Sure. Suppose you have a linked list, and have
allocated space for each node. Suppose you have
allocated space to hold all of the pointers to the
nodes (you might want to sort the linked list; it is much
easier to sort an array of pointers to linked list nodes
than it is to sort linked list nodes themselves - like
an old ADDROUT file).

After you dealloc all of the addresses to the nodes,
you are going to dealloc the space containing those addresses.

While you are deallocating the space pointed to by
a (linked list node) pointer you know the space
containing that pointer is going to be deallocated
as well, so it isn't necessary to initialize it.

In other words, if the pointer to the heap storage
being deallocated is, itself, in the heap, and going
to be deallocated, there is no need to set it to
null.

Chris
--
chris@xxxxxxxxx
pando.org
www.brilligware.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.