Nebula
Loading...
Searching...
No Matches
winmemory.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
12#include "core/config.h"
13#include "core/debug.h"
14
15namespace Memory
16{
17//------------------------------------------------------------------------------
21__forceinline void
22Copy(const void* from, void* to, size_t numBytes)
23{
24 if (numBytes > 0)
25 {
26 n_assert(0 != from);
27 n_assert(0 != to);
28 n_assert(from != to);
29 CopyMemory(to, from, numBytes);
30 }
31}
32
33//------------------------------------------------------------------------------
37template <typename T>
38__forceinline void
39CopyElements(const T* from, T* to, size_t numElements)
40{
41 if (numElements > 0)
42 {
43 n_assert(0 != from);
44 n_assert(0 != to);
45 n_assert(from != to);
46 CopyMemory((void*)to, (const void*)from, numElements * sizeof(T));
47 }
48}
49
50//------------------------------------------------------------------------------
54__forceinline void
55Move(const void* from, void* to, size_t numBytes)
56{
57 if (numBytes > 0)
58 {
59 n_assert(0 != from);
60 n_assert(0 != to);
61 n_assert(from != to);
62 MoveMemory(to, from, numBytes);
63 }
64}
65
66//------------------------------------------------------------------------------
70template <typename T>
71__forceinline void
72MoveElements(const T* from, T* to, size_t numElements)
73{
74 if (numElements > 0)
75 {
76 n_assert(0 != from);
77 n_assert(0 != to);
78 n_assert(from != to);
79 MoveMemory((void*)to, (const void*)from, numElements * sizeof(T));
80 }
81}
82
83//------------------------------------------------------------------------------
88__forceinline void
89CopyToGraphicsMemory(const void* from, void* to, size_t numBytes)
90{
91 // no special handling on the Win32 platform
92 Memory::Copy(from, to, numBytes);
93}
94
95//------------------------------------------------------------------------------
99__forceinline void
100Clear(void* ptr, size_t numBytes)
101{
102 ZeroMemory(ptr, numBytes);
103}
104
105//------------------------------------------------------------------------------
109__forceinline void
110Fill(void* ptr, size_t numBytes, unsigned char value)
111{
112 FillMemory(ptr, numBytes, value);
113}
114
115} // namespace Memory
116//------------------------------------------------------------------------------
Nebula debug macros.
#define n_assert(exp)
Definition debug.h:50
Nebula compiler specific defines and configuration.
Definition arenaallocator.h:31
__forceinline void Move(const void *from, void *to, size_t numBytes)
Move a chunk of memory, can handle overlapping regions.
Definition posixmemory.h:175
void Copy(const void *from, void *to, size_t numBytes)
Copy a chunk of memory (note the argument order is different from memcpy()!!!)
Definition osxmemory.cc:213
__forceinline void CopyElements(const T *from, T *to, size_t numElements)
Copy a chunk of memory (note the argument order is different from memcpy()!!!)
Definition posixmemory.h:209
void Fill(void *ptr, size_t numBytes, unsigned char value)
Fill memory with a specific byte.
Definition osxmemory.cc:239
__forceinline void MoveElements(const T *from, T *to, size_t numElements)
Move a chunk of memory, can handle overlapping regions.
Definition posixmemory.h:192
__forceinline void CopyToGraphicsMemory(const void *from, void *to, size_t numBytes)
Copy data from a system memory buffer to graphics resource memory.
Definition posixmemory.h:227
void Clear(void *ptr, size_t numBytes)
Overwrite a chunk of memory with 0's.
Definition osxmemory.cc:229