diff options
| author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-02-21 12:47:40 +0200 |
|---|---|---|
| committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-02-21 15:32:26 +0200 |
| commit | ba4b50118d26642a4e3603a5687b0cc1ca093396 (patch) | |
| tree | 9213f1b29ddfd9266eec6cbf12d82a89d14979f2 /include/godot_cpp/templates | |
| parent | 2f07eb07eea9e5ef3a6e9f8707f08cec77db579f (diff) | |
| download | redot-cpp-ba4b50118d26642a4e3603a5687b0cc1ca093396.tar.gz | |
Fix incorrect memory allocation in release builds.
Co-authored-by: lightyears <lightyears1998@hotmail.com>
Diffstat (limited to 'include/godot_cpp/templates')
| -rw-r--r-- | include/godot_cpp/templates/cowdata.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/godot_cpp/templates/cowdata.hpp b/include/godot_cpp/templates/cowdata.hpp index 38f9277..1753687 100644 --- a/include/godot_cpp/templates/cowdata.hpp +++ b/include/godot_cpp/templates/cowdata.hpp @@ -217,7 +217,7 @@ void CowData<T>::_unref(void *p_data) { } // free mem - Memory::free_static((uint8_t *)p_data); + Memory::free_static((uint8_t *)p_data, true); } template <class T> @@ -233,7 +233,7 @@ uint32_t CowData<T>::_copy_on_write() { /* in use by more than me */ uint32_t current_size = *_get_size(); - uint32_t *mem_new = (uint32_t *)Memory::alloc_static(_get_alloc_size(current_size)); + uint32_t *mem_new = (uint32_t *)Memory::alloc_static(_get_alloc_size(current_size), true); new (mem_new - 2) SafeNumeric<uint32_t>(1); // refcount *(mem_new - 1) = current_size; // size @@ -286,7 +286,7 @@ Error CowData<T>::resize(int p_size) { if (alloc_size != current_alloc_size) { if (current_size == 0) { // alloc from scratch - uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size); + uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true); ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY); *(ptr - 1) = 0; // size, currently none new (ptr - 2) SafeNumeric<uint32_t>(1); // refcount @@ -294,7 +294,7 @@ Error CowData<T>::resize(int p_size) { _ptr = (T *)ptr; } else { - uint32_t *_ptrnew = (uint32_t *)Memory::realloc_static(_ptr, alloc_size); + uint32_t *_ptrnew = (uint32_t *)Memory::realloc_static(_ptr, alloc_size, true); ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY); new (_ptrnew - 2) SafeNumeric<uint32_t>(rc); // refcount @@ -324,7 +324,7 @@ Error CowData<T>::resize(int p_size) { } if (alloc_size != current_alloc_size) { - uint32_t *_ptrnew = (uint32_t *)Memory::realloc_static(_ptr, alloc_size); + uint32_t *_ptrnew = (uint32_t *)Memory::realloc_static(_ptr, alloc_size, true); ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY); new (_ptrnew - 2) SafeNumeric<uint32_t>(rc); // refcount |
