mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 00:49:08 +00:00
feat(memory): add SMemCopy and SMemMove
This commit is contained in:
parent
60523c3fe8
commit
73e0097395
3 changed files with 79 additions and 0 deletions
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
constexpr size_t ALIGNMENT = 8;
|
||||
|
||||
|
||||
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags) {
|
||||
size_t alignedBytes = (bytes + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1);
|
||||
|
||||
|
|
@ -23,6 +25,10 @@ void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t
|
|||
}
|
||||
}
|
||||
|
||||
void SMemCopy(void* dst, void* src, size_t bytes) {
|
||||
memmove(dst, src, bytes);
|
||||
}
|
||||
|
||||
void SMemFill(void* ptr, size_t bytes, uint8_t value) {
|
||||
memset(ptr, value, bytes);
|
||||
}
|
||||
|
|
@ -39,6 +45,10 @@ void SMemFree(void* ptr, const char* filename, int32_t linenumber, uint32_t flag
|
|||
}
|
||||
}
|
||||
|
||||
void SMemMove(void* dst, void* src, size_t bytes) {
|
||||
memmove(dst, src, bytes);
|
||||
}
|
||||
|
||||
void* SMemReAlloc(void* ptr, size_t bytes, const char* filename, int32_t linenumber, uint32_t flags) {
|
||||
if (flags == 0xB00BEEE5) {
|
||||
return nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue