Merge pull request #113061 from Ivorforce/profile-alloc-fixes

Only call `GodotProfileAlloc` when the allocation actually happened.
This commit is contained in:
Thaddeus Crews 2025-11-24 10:21:29 -06:00
commit 56d766a2a7
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -110,9 +110,9 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
} else { } else {
mem = malloc(p_bytes + (prepad ? DATA_OFFSET : 0)); mem = malloc(p_bytes + (prepad ? DATA_OFFSET : 0));
} }
GodotProfileAlloc(mem, p_bytes + (prepad ? DATA_OFFSET : 0));
ERR_FAIL_NULL_V(mem, nullptr); ERR_FAIL_NULL_V(mem, nullptr);
GodotProfileAlloc(mem, p_bytes + (prepad ? DATA_OFFSET : 0));
if (prepad) { if (prepad) {
uint8_t *s8 = (uint8_t *)mem; uint8_t *s8 = (uint8_t *)mem;
@ -180,9 +180,9 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
} else { } else {
GodotProfileFree(mem); GodotProfileFree(mem);
mem = (uint8_t *)realloc(mem, p_bytes); mem = (uint8_t *)realloc(mem, p_bytes);
GodotProfileAlloc(mem, p_bytes);
ERR_FAIL_COND_V(mem == nullptr && p_bytes > 0, nullptr); ERR_FAIL_COND_V(mem == nullptr && p_bytes > 0, nullptr);
GodotProfileAlloc(mem, p_bytes);
return mem; return mem;
} }