realloc reactions ??

DanKarron at UCBVAX.BERKELEY.EDU DanKarron at UCBVAX.BERKELEY.EDU
Fri Feb 15 20:52:03 AEST 1991


I am curious about the realloc function. 

Usually I build a linked list
when you don't know how many elements of a table I need at the
start of some operation. With realloc, you can grow the end of your
table allocation block as you need the space, 
plus have the advantage of keeping all of the elements of your list 
in the form of an array. I think that this is really neat!

This means that many applications that formerly were implimented as
linked lists (single, or double,forward/backward linkages) can now be done as
growable/shrinkable arrays.

How does this work ? 

The documentation says that realloc'ed pointers can
be moved by realloc, but I have tested the pointers on entry and exit and they
never seem to move. Does realloc create holes in your heap ? 
Which way is the new preferred practice: linked lists or realloc'd arrays ?

Cheers!
Dan(who wants to unlink and array)

+-----------------------------------------------------------------------------+
| karron at nyu.edu (E-mail alias that will always find me)                      |
| Fax: 212 263 7190           *           Dan Karron, Research Associate      |
| . . . . . . . . . . . . . . *           New York University Medical Center  |
| 560 First Avenue           \*\    Pager <1> (212) 397 9330                  |
| New York, New York 10016    \**\        <2> 10896   <3> <your-number-here>  |
| (212) 263 5210               \***\_________________________________________ |
| Main machine: karron.med.nyu.edu (128.122.135.3) IRIS 85GT                  |
+-----------------------------------------------------------------------------+

NOTE PHONE NUMBER CHANGE: The Med Ctr has changed from 340 to 263 exchange.



More information about the Comp.sys.sgi mailing list