Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IceMemoryMacros.h File Reference

Go to the source code of this file.

Macros

#define SIZEOFOBJECT   sizeof(*this)
 Gives the size of current object. Avoid some mistakes (e.g. "sizeof(this)"). More...
 
#define DELETESINGLE(x)   { delete x; x = null; }
 Deletes an instance of a class. More...
 
#define DELETEARRAY(x)   { delete []x; x = null; }
 Deletes an array. More...
 
#define SAFE_RELEASE(x)   if (x) { (x)->Release(); (x) = null; }
 Safe D3D-style release. More...
 
#define SAFE_DESTRUCT(x)   if (x) { (x)->SelfDestruct(); (x) = null; }
 Safe ICE-style release. More...
 
#define CHECKALLOC(x)   if(!x) return false;
 
#define SAFE_ALLOC(ptr, type, count)   DELETEARRAY(ptr); ptr = new type[count]; CHECKALLOC(ptr);
 Standard allocation cycle. More...
 

Functions

inline_ void ZeroMemory (void *addr, udword size)
 
inline_ void FillMemory (void *dest, udword size, ubyte val)
 
inline_ void StoreDwords (udword *dest, udword nb, udword value)
 
inline_ void CopyMemory (void *dest, const void *src, udword size)
 
inline_ void MoveMemory (void *dest, const void *src, udword size)
 

Detailed Description

Contains all memory macros.

Author
Pierre Terdiman
Date
April, 4, 2000

Definition in file IceMemoryMacros.h.

Macro Definition Documentation

#define CHECKALLOC (   x)    if(!x) return false;

Definition at line 100 of file IceMemoryMacros.h.

#define DELETEARRAY (   x)    { delete []x; x = null; }

Deletes an array.

Definition at line 93 of file IceMemoryMacros.h.

Referenced by Opcode::SweepAndPrune::Init(), and Opcode::Internal::~Internal().

#define DELETESINGLE (   x)    { delete x; x = null; }

Deletes an instance of a class.

Definition at line 92 of file IceMemoryMacros.h.

Referenced by ReleasePruningSorters().

#define SAFE_ALLOC (   ptr,
  type,
  count 
)    DELETEARRAY(ptr); ptr = new type[count]; CHECKALLOC(ptr);

Standard allocation cycle.

Definition at line 104 of file IceMemoryMacros.h.

#define SAFE_DESTRUCT (   x)    if (x) { (x)->SelfDestruct(); (x) = null; }

Safe ICE-style release.

Definition at line 95 of file IceMemoryMacros.h.

#define SAFE_RELEASE (   x)    if (x) { (x)->Release(); (x) = null; }

Safe D3D-style release.

Definition at line 94 of file IceMemoryMacros.h.

#define SIZEOFOBJECT   sizeof(*this)

Gives the size of current object. Avoid some mistakes (e.g. "sizeof(this)").

Definition at line 90 of file IceMemoryMacros.h.

Referenced by GetNodeSize().

Function Documentation

inline_ void CopyMemory ( void *  dest,
const void *  src,
udword  size 
)

Copies a buffer.

Parameters
addr[in] destination buffer address
addr[in] source buffer address
size[in] buffer length
See Also
ZeroMemory
FillMemory
StoreDwords
MoveMemory

Definition at line 78 of file IceMemoryMacros.h.

References VsnetOSS::memcpy().

Referenced by Container::Add(), Matrix3x3::Copy(), Matrix4x4::Copy(), Matrix3x3::Matrix3x3(), Matrix4x4::Matrix4x4(), and Container::operator=().

78 { memcpy(dest, src, size); }
inline_ void FillMemory ( void *  dest,
udword  size,
ubyte  val 
)

Fills a buffer with a given byte.

Parameters
addr[in] buffer address
size[in] buffer length
val[in] the byte value
See Also
StoreDwords
ZeroMemory
CopyMemory
MoveMemory

Definition at line 37 of file IceMemoryMacros.h.

37 { memset(dest, val, size); }
inline_ void MoveMemory ( void *  dest,
const void *  src,
udword  size 
)

Moves a buffer.

Parameters
addr[in] destination buffer address
addr[in] source buffer address
size[in] buffer length
See Also
ZeroMemory
FillMemory
StoreDwords
CopyMemory

Definition at line 88 of file IceMemoryMacros.h.

88 { memmove(dest, src, size); }
inline_ void StoreDwords ( udword dest,
udword  nb,
udword  value 
)

Fills a buffer with a given dword.

Parameters
addr[in] buffer address
nb[in] number of dwords to write
value[in] the dword value
See Also
FillMemory
ZeroMemory
CopyMemory
MoveMemory
Warning
writes nb*4 bytes !

Definition at line 48 of file IceMemoryMacros.h.

49  {
50  // The asm code below **SHOULD** be equivalent to one of those C versions
51  // or the other if your compiled is good: (checked on VC++ 6.0)
52  //
53  // 1) while(nb--) *dest++ = value;
54  //
55  // 2) for(udword i=0;i<nb;i++) dest[i] = value;
56  //
57  /*_asm push eax
58  _asm push ecx
59  _asm push edi
60  _asm mov edi, dest
61  _asm mov ecx, nb
62  _asm mov eax, value
63  _asm rep stosd
64  _asm pop edi
65  _asm pop ecx
66  _asm pop eax*/
67  while(nb--) *dest++ = value;
68  }
inline_ void ZeroMemory ( void *  addr,
udword  size 
)

Clears a buffer.

Parameters
addr[in] buffer address
size[in] buffer length
See Also
FillMemory
StoreDwords
CopyMemory
MoveMemory

Definition at line 27 of file IceMemoryMacros.h.

Referenced by LookAtHelper(), main(), Matrix3x3::Zero(), and Matrix4x4::Zero().

27 { memset(addr, 0, size); }