diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-02 21:41:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 21:41:42 +0200 |
commit | e0d610203c5194400a5932f36ae0d96c8ede7f0f (patch) | |
tree | 68c2fb70ffafe632d82a4292ca8c0fade49da448 /modules | |
parent | 9e1e4defefdd2e08eb1a8672c27bef25c58de88b (diff) | |
parent | f7dad789e958fed81bb167b14c5add45ef723cf9 (diff) |
Merge pull request #30254 from bojidar-bg/30224-docdata-generate
Fix various memory leaks and errors
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdnative/gdnative.cpp | 18 | ||||
-rw-r--r-- | modules/gdnative/gdnative.h | 2 |
2 files changed, 8 insertions, 12 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index a27935bfe2..4eb9a2a0a3 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -48,7 +48,7 @@ static const bool default_reloadable = true; // Defined in gdnative_api_struct.gen.cpp extern const godot_gdnative_core_api_struct api_struct; -Map<String, Vector<Ref<GDNative> > > *GDNativeLibrary::loaded_libraries = NULL; +Map<String, Vector<Ref<GDNative> > > GDNativeLibrary::loaded_libraries; GDNativeLibrary::GDNativeLibrary() { config_file.instance(); @@ -57,10 +57,6 @@ GDNativeLibrary::GDNativeLibrary() { load_once = default_load_once; singleton = default_singleton; reloadable = default_reloadable; - - if (GDNativeLibrary::loaded_libraries == NULL) { - GDNativeLibrary::loaded_libraries = memnew((Map<String, Vector<Ref<GDNative> > >)); - } } GDNativeLibrary::~GDNativeLibrary() { @@ -318,10 +314,10 @@ bool GDNative::initialize() { #endif if (library->should_load_once()) { - if (GDNativeLibrary::loaded_libraries->has(lib_path)) { + if (GDNativeLibrary::loaded_libraries.has(lib_path)) { // already loaded. Don't load again. // copy some of the stuff instead - this->native_handle = (*GDNativeLibrary::loaded_libraries)[lib_path][0]->native_handle; + this->native_handle = GDNativeLibrary::loaded_libraries[lib_path][0]->native_handle; initialized = true; return true; } @@ -377,11 +373,11 @@ bool GDNative::initialize() { initialized = true; - if (library->should_load_once() && !GDNativeLibrary::loaded_libraries->has(lib_path)) { + if (library->should_load_once() && !GDNativeLibrary::loaded_libraries.has(lib_path)) { Vector<Ref<GDNative> > gdnatives; gdnatives.resize(1); gdnatives.write[0] = Ref<GDNative>(this); - GDNativeLibrary::loaded_libraries->insert(lib_path, gdnatives); + GDNativeLibrary::loaded_libraries.insert(lib_path, gdnatives); } return true; @@ -395,7 +391,7 @@ bool GDNative::terminate() { } if (library->should_load_once()) { - Vector<Ref<GDNative> > *gdnatives = &(*GDNativeLibrary::loaded_libraries)[library->get_current_library_path()]; + Vector<Ref<GDNative> > *gdnatives = &GDNativeLibrary::loaded_libraries[library->get_current_library_path()]; if (gdnatives->size() > 1) { // there are other GDNative's still using this library, so we actually don't terminate gdnatives->erase(Ref<GDNative>(this)); @@ -405,7 +401,7 @@ bool GDNative::terminate() { // we're the last one, terminate! gdnatives->clear(); // whew this looks scary, but all it does is remove the entry completely - GDNativeLibrary::loaded_libraries->erase(GDNativeLibrary::loaded_libraries->find(library->get_current_library_path())); + GDNativeLibrary::loaded_libraries.erase(GDNativeLibrary::loaded_libraries.find(library->get_current_library_path())); } } diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index 005d1d2bff..408af26753 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -47,7 +47,7 @@ class GDNative; class GDNativeLibrary : public Resource { GDCLASS(GDNativeLibrary, Resource); - static Map<String, Vector<Ref<GDNative> > > *loaded_libraries; + static Map<String, Vector<Ref<GDNative> > > loaded_libraries; friend class GDNativeLibraryResourceLoader; friend class GDNative; |