Dave's Brain

Browse - programming tips - zeromemory

Date: 2004aug22
Title: win32: Clearing memory the modern way

In the olden days I used to code:

	memset(&MyStruct, 0, sizeof(MyStruct));

Now I write:

	ZeroMemory(&MyStruct, sizeof(MyStruct));

Which is on character longer but reads nicer.

This is defined in the Win32 headers as:

#define ZeroMemory(Destination,Length) memset((Destination),0,(Length))

Add a comment

Sign in to add a comment
Copyright © 2008, dave - Code on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License.