Repository navigation
GDExtension: Pass count when freeing method and property lists for script instances - #89055
Merged
akien-mga merged 1 commit intoMar 4, 2024
Merged
Conversation
This was referenced Mar 1, 2024
dsnopek
force-pushed
the
gdextension-script-free-lists
branch
from
March 1, 2024 17:20
3a566a9 to
6bea6b5
Compare
AThousandShips
approved these changes
Mar 1, 2024
AThousandShips
left a comment
Member
There was a problem hiding this comment.
Code looks good and the feature makes sense
dsnopek
force-pushed
the
gdextension-script-free-lists
branch
from
March 1, 2024 18:10
6bea6b5 to
27ea7ed
Compare
Contributor
Author
|
Thinking about this a little more, I think now that the I'll update this PR to do that a little later. |
dsnopek
force-pushed
the
gdextension-script-free-lists
branch
from
March 2, 2024 16:13
27ea7ed to
0badf07
Compare
AThousandShips
approved these changes
Mar 2, 2024
Contributor
Author
|
I just pushed the changes to dynamically allocate the deprecated native info struct! I re-tested this with the Luau GDExtension, using the older interface, and everything still seems to be working. |
Member
|
Thanks! |
BendyLand
pushed a commit
to BendyLand/voltaire
that referenced
this pull request
Aug 2, 2026
…free-lists GDExtension: Pass count when freeing method and property lists for script instances
BendyLand
pushed a commit
to BendyLand/voltaire
that referenced
this pull request
Aug 2, 2026
…free-lists GDExtension: Pass count when freeing method and property lists for script instances
wangshucheng
pushed a commit
to wangshucheng/godot
that referenced
this pull request
Aug 27, 2026
…free-lists GDExtension: Pass count when freeing method and property lists for script instances
Shane-Gadsby
pushed a commit
to Shane-Gadsby/godotwebgpu
that referenced
this pull request
Sep 21, 2026
…free-lists GDExtension: Pass count when freeing method and property lists for script instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the
free_property_listandfree_method_listfunctions onGDExtensionScriptInstanceInfo2don't accept the number of items in the list. Since the GDExtension probably allocated memory for each item in the list, it will need to loop over all the elements in the list in order to free that memory.In order to work around this, all existing GDExtensions that provide a scripting language do some sort of hack to save the list count. For example, the Luau bindings allocate the list with some extra room at the front to stash the count and then do some pointer math:
https://github.com/Fumohouse/godot-luau-script/blob/69d5e02fc1e94101cf31d7bd9b384ad2423cdd96/src/luau_script.h#L222
In any case, none of these hacks or workarounds would be necessary if Godot simply passed the count to the
free_property_listandfree_method_listfunctions, which is what this PR does!(In addition to these changes, I also wrapped more of the code to support deprecated structs in
ScriptInstanceExtensionwith#ifndef DISABLE_DEPRECATEDto make builds without deprecated code a little lighter.)