Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

How to zero your memory?

, 23 Aug 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
I always use a home-made macro to zero my struct's and class's:#define ZEROMEMORY ZeroMemory (this, sizeof (*this))Sample1:struct S1 { double x; long i; char s[255+1]; S1 () { ZEROMEMORY; } };Sample2:class foo { private: double x[16]; char a,b,c; foo () {...
I always use a home-made macro to zero my struct's and class's:
#define ZEROMEMORY ZeroMemory (this, sizeof (*this))
Sample1:
 
struct S1 { double x; long i; char s[255+1]; S1 () { ZEROMEMORY; } };
 
Sample2:
class foo {
 private:
   double x[16];
   char a,b,c;
   foo () { ZEROMEMORY; }
};

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jose David Pujo
Software Developer (Senior) Freelancer
Spain Spain
No Biography provided

Comments and Discussions

 
Generalhow to add the number Pinmembereg_Anubhava11-Nov-11 3:31 
GeneralReason for my vote of 2 This is to dangerous. Another progra... PinmemberMartin Richter [MVP C++]12-Sep-11 20:57 
GeneralReason for my vote of 5 Nice one. PinmemberMalli_S9-Sep-11 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150331.1 | Last Updated 23 Aug 2011
Article Copyright 2011 by Jose David Pujo
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid