On 28 Sep 2000 11:06:47 -0400, Warp wrote:
>dis### [at] hlavacek-partner cz wrote:
>: $(SUBJ) can be useful and not so difficult feature to implement.
>
> Actually dynamic arrays in C are not trivial.
Maybe not trivial but pretty easy. Just realloc to exponentially growing
sizes. My ant library (http://www.hjp.at/programs/ant/) includes a few
handy macros for this (Caveat - they have a subtle bug which hasn't
bitten me so far - bonus points if you can spot it).
The main program with dynamic arrays in C is that the code which uses
them must be aware that they are dynamic and may change location as well
as size. It must never preserve any pointers into the array across a
point where the array may be resized, but must recompute them from
indexes or stick to using indexes.
hp
--
|_|_) | Sysadmin WSR | vor dem rechner.
__/ | http://www.hjp.at/ | at.linux, 2000-09-24
Post a reply to this message
|