[Bf-blender-cvs] [299ba77cc9b] functions: fix false positive memory leak
Jacques Lucke
noreply at git.blender.org
Wed Jul 24 19:12:08 CEST 2019
Commit: 299ba77cc9bcec91bbd4d0801741624c25131d32
Author: Jacques Lucke
Date: Wed Jul 24 16:15:06 2019 +0200
Branches: functions
https://developer.blender.org/rB299ba77cc9bcec91bbd4d0801741624c25131d32
fix false positive memory leak
===================================================================
M source/blender/functions/functions/switch.cpp
===================================================================
diff --git a/source/blender/functions/functions/switch.cpp b/source/blender/functions/functions/switch.cpp
index d6b87cae319..8a7210ca709 100644
--- a/source/blender/functions/functions/switch.cpp
+++ b/source/blender/functions/functions/switch.cpp
@@ -70,14 +70,20 @@ static SharedFunction build_bool_switch_function(SharedType &data_type)
return fn;
}
+using CacheMap = Map<SharedType, SharedFunction>;
+BLI_LAZY_INIT_STATIC(CacheMap, get_cache)
+{
+ return {};
+}
+
SharedFunction &GET_FN_bool_switch(SharedType &data_type)
{
- static Map<SharedType, SharedFunction> functions;
- if (!functions.contains(data_type)) {
+ CacheMap &cache = get_cache();
+ if (!cache.contains(data_type)) {
SharedFunction fn = build_bool_switch_function(data_type);
- functions.add(data_type, fn);
+ cache.add(data_type, fn);
}
- return functions.lookup_ref(data_type);
+ return cache.lookup_ref(data_type);
}
} // namespace Functions
More information about the Bf-blender-cvs
mailing list