POV-Ray : Newsgroups : povray.programming : Growing arrays : Re: Growing arrays Server Time
28 Jul 2024 14:18:14 EDT (-0400)
  Re: Growing arrays  
From: Peter J  Holzer
Date: 29 Sep 2000 16:01:45
Message: <slrn8t9rn0.r5e.hjp-usenet@teal.h.hjp.at>
On 28 Sep 2000 11:06:47 -0400, Warp wrote:
>dis### [at] hlavacek-partnercz 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.