summaryrefslogtreecommitdiffstats
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-02-26 12:54:17 -0600
committerGitHub <noreply@github.com>2024-02-26 12:54:17 -0600
commite55b792fea513b4c1f13939ca00c28e06b8d4454 (patch)
tree07e3909a3ba8ba424289cc05afbe6ed364e1d862 /src/core/memory.cpp
parentf90085917b16c3daff7b2d195db9bf222119eea1 (diff)
parentb173a4d93551bbaabd3c4c26104f3c098055efae (diff)
downloadredot-cpp-e55b792fea513b4c1f13939ca00c28e06b8d4454.tar.gz
Merge pull request #1383 from bruvzg/memalign
[Core] Improve `CowData` and `Memory` metadata alignment.
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp12
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);
}