Re: Dynamic Array and Invalid Pointer

From: Rudy Velthuis (rvelthuis_at_gmx.de)
Date: 04/28/04


Date: Wed, 28 Apr 2004 22:02:00 +0200

At 20:53:03, 28.04.2004, zdrakec wrote:

> Alas, I have tried this also. Same result.
>
> Thanks,
> zdrakec
>
> "zdrakec" wrote in message
> news:39239f63.0404280742.2f560cc1@posting.google.com...
> [...]
> > If I attempt to free the [dynamic] array with
> >
> > (dtID := nil);
>
> That's no way to treat an array. An array is not a pointer, didn't
> anybody tell you? Just SetLength it to zero elements.

Er...

  dtID := nil;

is a valid way of getting rid of (or actually, decrementing the reference
count of) a dynamic array. After all, a dynamic array *is* a pointer.

-- 
Rudy Velthuis
"Egotist: a person more interested in himself than in me."
    - Ambrose Bierce (1842-1914)


Relevant Pages

  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
    (comp.lang.c)
  • Re: Array of classes
    ... >class CSomeclass ... >Then in the code I create a pointer to this class definition ... to an array of objects of some given size n, you'd have to set things up as ... treating elements of the MyClass dynamic array as if they were each a ...
    (comp.lang.cpp)
  • Re: Who owns the variable in my header file ?
    ... to check the subscripts to the array and trap on error conditions. ... cast one type of pointer into another; you wouldn't then be able to step ... language trying to be C like, ... One reason being that the programmer can possible ...
    (comp.lang.c)
  • Re: How can I quickly copy a CONST to a typed VAR
    ... Or an invalid pointer ... A dynamic array is lain out like this in memory: ... ElementCount aren't there. ... without the bookkeeping information that a dynamic array has. ...
    (alt.comp.lang.borland-delphi)
  • Re: why cannot assign to function call
    ... hypothetical C-like languages, ... sizeof business would still indicate that a pointer was being passed. ... talk about variables of an array type. ... the earlier version of the standard didn't have numbered ...
    (comp.lang.python)