Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable)be banned ?



SizeOf(Buffer);

What if Buffer is changed from a static array to a dynamic array.

SizeOf doesn't work for dynamic arrays.

Another reason why not to use SizeOf like that.

One main reason I started to program in TurboPascal and later Delphi is that
it's more easy to change code in Delphi without running into all kinds of
stupid changes and/or bugs everywhere, sometimes some smartness is needed as
well.

Using SizeOf on static buffers is clearly not very smart <- bug prone.

Bye,
Skybuck.


.



Relevant Pages

  • Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable)be banned ?
    ... What if Buffer is changed from a static array to a dynamic array. ... SizeOf doesn't work for dynamic arrays. ...
    (alt.comp.lang.borland-delphi)
  • RE: ADSI script for IIS 5.0 can not run in IIS 6.0
    ... Problem fixed by changing the array for ServerBindings from dynamic array to ... static array. ... But do not know the reason. ...
    (microsoft.public.inetserver.iis)
  • Re: Whats wrong with this code ? (struct serialization to raw byte str
    ... but any particular reason for the cast? ... to write sizeof *in since sizeof is an operator when applied to ... Alternatively, you could directly assign "Simple Text" to in->s as long as you remember that different instances of string literals need not refer to separate blocks of memory, and this block of memory may not be modifiable. ... newline, and two many characters without a newline is rather hard to ...
    (comp.lang.c)
  • Re: CreateProcess not work on Vista
    ... Whenever you call an API function, and it fails, you MUST call ... and after the CreateProcess you must ReleaseBuffer ... ZeroMemory (&si, sizeof (si)); ... Without knowing the reason for the error, you have no idea why it failed. ...
    (microsoft.public.vc.mfc)
  • Re: Any way to take a word as input from stdin ?
    ... why sizeof **pc and not sizeof *pc? ... Given that you have idx keeping track of things, I see no reason to ... you always pass a pointer and that *pc++ reminds of that i am working ... *must* be accompanied by call to free, other wise we will have a memory ...
    (comp.lang.c)