IceMemoryMacros.h
Go to the documentation of this file.
1 
8 
11 // Include Guard
12 #ifndef __ICEMEMORYMACROS_H__
13 #define __ICEMEMORYMACROS_H__
14 
15 #undef ZeroMemory
16 #undef CopyMemory
17 #undef MoveMemory
18 #undef FillMemory
19 
27  inline_ void ZeroMemory(void* addr, udword size) { memset(addr, 0, size); }
28 
37  inline_ void FillMemory(void* dest, udword size, ubyte val) { memset(dest, val, size); }
38 
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 #if defined(_MSC_VER) && not defined(_WIN64)
58  _asm push eax
59  _asm push ecx
60  _asm push edi
61  _asm mov edi, dest
62  _asm mov ecx, nb
63  _asm mov eax, value
64  _asm rep stosd
65  _asm pop edi
66  _asm pop ecx
67  _asm pop eax
68 #else
69  while(nb--) *dest++ = value;
70 #endif
71  }
72 
81  inline_ void CopyMemory(void* dest, const void* src, udword size) { memcpy(dest, src, size); }
82 
91  inline_ void MoveMemory(void* dest, const void* src, udword size) { memmove(dest, src, size); }
92 
93  #define SIZEOFOBJECT sizeof(*this)
94  //#define CLEAROBJECT { memset(this, 0, SIZEOFOBJECT); }
95  #define DELETESINGLE(x) if (x) { delete x; x = null; }
96  #define DELETEARRAY(x) if (x) { delete []x; x = null; }
97  #define SAFE_RELEASE(x) if (x) { (x)->Release(); (x) = null; }
98  #define SAFE_DESTRUCT(x) if (x) { (x)->SelfDestruct(); (x) = null; }
99 
100 #ifdef __ICEERROR_H__
101  #define CHECKALLOC(x) if(!x) return SetIceError("Out of memory.", EC_OUT_OF_MEMORY);
102 #else
103  #define CHECKALLOC(x) if(!x) return false;
104 #endif
105 
107  #define SAFE_ALLOC(ptr, type, count) DELETEARRAY(ptr); ptr = new type[count]; CHECKALLOC(ptr);
108 
109 #endif // __ICEMEMORYMACROS_H__
inline_ void StoreDwords(udword *dest, udword nb, udword value)
inline_ void FillMemory(void *dest, udword size, ubyte val)
png_uint_32 size
Definition: png.h:1521
png_voidp int value
Definition: png.h:2113
#define inline_
unsigned int udword
sizeof(udword) must be 4
Definition: IceTypes.h:65
unsigned char ubyte
sizeof(ubyte) must be 1
Definition: IceTypes.h:61
int val
Definition: jpeglib.h:956
inline_ void CopyMemory(void *dest, const void *src, udword size)
inline_ void ZeroMemory(void *addr, udword size)
inline_ void MoveMemory(void *dest, const void *src, udword size)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:38