diff options
author | Marc Gilleron <marc.gilleron@gmail.com> | 2021-01-07 01:05:12 +0000 |
---|---|---|
committer | Marc Gilleron <marc.gilleron@gmail.com> | 2021-01-07 01:05:12 +0000 |
commit | fb71edd45b2473bf0ac502c777a1850fb564087e (patch) | |
tree | 5d7a48365313cd54a2a763efa85728c36cf7ed86 /src/core/NodePath.cpp | |
parent | 43828ebb3931b9117ad57f08cc457e052fdfd631 (diff) | |
download | redot-cpp-fb71edd45b2473bf0ac502c777a1850fb564087e.tar.gz |
Fix container and string leaks
Some functions return a new instance of such containers,
but instead we made a copy of them, without taking ownership of the
original created by the function.
Now we use a specific constructor taking ownership on the godot_* struct.
Diffstat (limited to 'src/core/NodePath.cpp')
-rw-r--r-- | src/core/NodePath.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core/NodePath.cpp b/src/core/NodePath.cpp index 37ab2a3..bc069b7 100644 --- a/src/core/NodePath.cpp +++ b/src/core/NodePath.cpp @@ -27,8 +27,7 @@ NodePath::NodePath(const char *contents) { String NodePath::get_name(const int idx) const { godot_string str = godot::api->godot_node_path_get_name(&_node_path, idx); - - return *(String *)&str; + return String(str); } int NodePath::get_name_count() const { @@ -37,7 +36,7 @@ int NodePath::get_name_count() const { String NodePath::get_subname(const int idx) const { godot_string str = godot::api->godot_node_path_get_subname(&_node_path, idx); - return *(String *)&str; + return String(str); } int NodePath::get_subname_count() const { @@ -54,17 +53,16 @@ bool NodePath::is_empty() const { NodePath NodePath::get_as_property_path() const { godot_node_path path = godot::core_1_1_api->godot_node_path_get_as_property_path(&_node_path); - return *(NodePath *)&path; + return NodePath(path); } String NodePath::get_concatenated_subnames() const { godot_string str = godot::api->godot_node_path_get_concatenated_subnames(&_node_path); - return *(String *)&str; + return String(str); } NodePath::operator String() const { godot_string str = godot::api->godot_node_path_as_string(&_node_path); - - return *(String *)&str; + return String(str); } bool NodePath::operator==(const NodePath &other) { |