Mail Archives: djgpp/1998/03/31/14:02:05
Myknees wrote:
> Since the way you access the data is by going down the chain of elements
> (nodes) in order, it is very slow if you have a long list where you won't be
> using the elements in order. An alternative is to have a dynamically-allocated
> array of pointers to the structs. That's much faster for random access and
> doesn't cost more in memory, since the structs don't need to contain a pointer
> to the next struct. Of course, when you use an array you lose the ability to
> insert and delete elements easily and efficiently.
I know that dynamic allocations by malloc are kept in a linked list of memory
blocks + overhead of data. Is there any operation involving this list, which is
not of o(1)? (Well, except for freeing it all?) If so, why linked lists?
BTW,
This pool (heap?) of dynamic allocated memory is shared with other programs or
tasks? If so, how come I get dynamic and non dynamic allocations in the same
segment of memory?
If not, why should I free everything (or let it be done for me)? Could this memory
be still marked as taken even after my program has terminated?
---------------------------------------------
Noam Rotem
John Bryce Training Centre
Tel Aviv, Israel.
03-7535803
=============================================
- Raw text -