65.9K
CodeProject is changing. Read more.
Home

How to zero your memory?

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.25/5 (3 votes)

Aug 23, 2011

CPOL
viewsIcon

10840

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; }
};