Re: How do I delete a folder through code?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Thu, 8 May 2008 21:31:08 -0700, "Alexander Grigoriev"
<alegr@xxxxxxxxxxxxx> wrote:

Actually, {0} initialization is done by the compiler by emitting memset
equivalent, which is pretty much the same as ZeroMemory produces.

The last time I looked at this, which was a looooooong time ago,
initialized static duration data was stored in the DATA segment, where it
added to the executable size, while uninitialized static data was stored in
the BSS segment, where it took up no space in the executable. Given that
the language specifies that uninitialized static data is set to zero
anyway, SOP is to never explicitly initialize static duration data to zero.

Data stored in the BSS is initialized to zero by a memset equivalent, and
this is also done for local non-static variables, i.e. auto variables, as
you said. I'm unaware I ever used a compiler that would create an image of
the initialization data and copy it to these objects. Thus, there is no
reason not to use {0} on the variables for which it is appropriate, namely,
autos. In Windows programming, it's even more common to see things like:

T x = { sizeof(T) }; // x is auto

This is an idiomatic way to initialize a data structure whose first member
specifies the size, while concomitantly zero-initializing the rest of the
struct, which is done with memset equivalent.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: Problem only in release version!
    ... not executed in Release mode (I believe, but I also thought Debug ... initialized variables to zero, ... The Release version will not initialize anything 'naturally' ... >>the contents of the memory addresses they happen to get assigned to). ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Problem only in release version!
    ... The debug version doesn't initialize anything to zero that isn't ... the debug heap manager sets memory to certain non-zero values ...
    (microsoft.public.dotnet.languages.vc)
  • Re: [crash, bisected] Re: [PATCH 3/4] x86_64: Fold pda into per cpu area
    ... to initialize the kernel segments. ... The zero-based PDA mechanism requires the introduction of a new ELF ... Why are we doing a zero based pda? ... offset in the segment register to allow for everything to work as ...
    (Linux-Kernel)
  • Re: Storage of Variables
    ... code at entry to a function zero out the stack. ... In C, there is really no such concept as a heap, though you could ... the bss segment. ... And to initialize the data segment, ...
    (comp.os.linux.misc)
  • Re: simple PRNG?
    ... When I play word games, ... And I certainly don't hate you. ... I think you were being a little mischievous in not mentioning the seed value of zero earlier. ... that he shouldn't initialize it to zero". ...
    (comp.lang.c)