Skip to content

Commit

Permalink
Merge pull request #85216 from bruvzg/ios_fix_extension_init_realloc
Browse files Browse the repository at this point in the history
[iOS] Fix GDExtension init callback array reallocation.
  • Loading branch information
akien-mga committed Nov 22, 2023
2 parents f824a67 + 8e06a10 commit 923ef2b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions platform/ios/os_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@

void add_ios_init_callback(init_callback cb) {
if (ios_init_callbacks_count == ios_init_callbacks_capacity) {
void *new_ptr = realloc(ios_init_callbacks, sizeof(cb) * 32);
void *new_ptr = realloc(ios_init_callbacks, sizeof(cb) * (ios_init_callbacks_capacity + 32));
if (new_ptr) {
ios_init_callbacks = (init_callback *)(new_ptr);
ios_init_callbacks_capacity += 32;
} else {
ERR_FAIL_MSG("Unable to allocate memory for extension callbacks.");
}
}
if (ios_init_callbacks_capacity > ios_init_callbacks_count) {
ios_init_callbacks[ios_init_callbacks_count] = cb;
++ios_init_callbacks_count;
}
ios_init_callbacks[ios_init_callbacks_count++] = cb;
}

void register_dynamic_symbol(char *name, void *address) {
Expand Down

0 comments on commit 923ef2b

Please sign in to comment.