From: Andrew Inggs <Andrew.I<nggs@te...> - 2002-06-14 13:24:16
> From: Joerg Bruehe [mailto:joerg@...]
> Luke Dunstan wrote:
> > I'm not sure I understand you correctly, but are you saying
> > that you dynamically allocate an initial array, then allocate
> > additional blocks without freeing or resizing the original
> > array, and treat the separate blocks as one array?
> Not exactly: The variable is declared as an array with a fixed size,
> so it is statically allocated. When more elements are needed,
> then the additional space is allocated, and from its address the
> index for these elements is computed. (Luckily, C does not do
> array bounds checking.)
> All those who say this is a bad design are completely right ;-)
> The clean design would use pointers and fully dynamic allocation,
> but the large existing code uses the "array [ index ]" notation
> throughout, even in a nested fashion: "array [ array [ index ]]".
> (The variable in question is a syntax tree, the whole program
> is a Pascal-to-C translator.)
> I still try to avoid changing this into pointer notation.
I must be missing something. Why not just use realloc? You could
still use the array[index] notation.
Get latest updates about Open Source Projects, Conferences and News.