diff options
| author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-02-05 19:26:45 +0200 |
|---|---|---|
| committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-02-05 19:26:45 +0200 |
| commit | b173a4d93551bbaabd3c4c26104f3c098055efae (patch) | |
| tree | b3ad3a4cd0f3f45421d0b550ac41219872d540d7 /src/core | |
| parent | 36847f6af0be548bae96429fa84d59f407b51582 (diff) | |
| download | redot-cpp-b173a4d93551bbaabd3c4c26104f3c098055efae.tar.gz | |
[Core] Improve `CowData` and `Memory` metadata alignment.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/memory.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 8118511..f330c23 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -41,12 +41,12 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { bool prepad = p_pad_align; #endif - void *mem = internal::gdextension_interface_mem_alloc(p_bytes + (prepad ? PAD_ALIGN : 0)); + void *mem = internal::gdextension_interface_mem_alloc(p_bytes + (prepad ? DATA_OFFSET : 0)); ERR_FAIL_NULL_V(mem, nullptr); if (prepad) { uint8_t *s8 = (uint8_t *)mem; - return s8 + PAD_ALIGN; + return s8 + DATA_OFFSET; } else { return mem; } @@ -69,10 +69,10 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { #endif if (prepad) { - mem -= PAD_ALIGN; - mem = (uint8_t *)internal::gdextension_interface_mem_realloc(mem, p_bytes + PAD_ALIGN); + mem -= DATA_OFFSET; + mem = (uint8_t *)internal::gdextension_interface_mem_realloc(mem, p_bytes + DATA_OFFSET); ERR_FAIL_NULL_V(mem, nullptr); - return mem + PAD_ALIGN; + return mem + DATA_OFFSET; } else { return (uint8_t *)internal::gdextension_interface_mem_realloc(mem, p_bytes); } @@ -88,7 +88,7 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) { #endif if (prepad) { - mem -= PAD_ALIGN; + mem -= DATA_OFFSET; } internal::gdextension_interface_mem_free(mem); } |
