Blender Git Loki
Git Commits -> Revision a3ad5ab
Revision a3ad5ab by Jacques Lucke (master) December 17, 2021, 14:42 (GMT) |
Allocator: simplify using guarded allocator in C++ code Using the `MEM_*` API from C++ code was a bit annoying: * When converting C to C++ code, one often has to add a type cast on returned `void *`. That leads to having the same type name three times in the same line. This patch reduces the amount to two and removes the `sizeof(...)` from the line. * The existing alternative of using `OBJECT_GUARDED_NEW` looks a out of place compared to other allocation methods. Sometimes `MEM_CXX_CLASS_ALLOC_FUNCS` can be used when structs are defined in C++ code. It doesn't look great but it's definitely better. The downside is that it makes the name of the allocation less useful. That's because the same name is used for all allocations of a type, independend of where it is allocated. This patch introduces three new functions: `MEM_new`, `MEM_cnew` and `MEM_delete`. These cover the majority of use cases (array allocation is not covered). The `OBJECT_GUARDED_*` macros are removed because they are not needed anymore. Differential Revision: https://developer.blender.org/D13502 |
Commit Details:
Full Hash: a3ad5abf2fe85d623f9e78fefc34e27bdc14632e
Parent Commit: c0d96ca
Lines Changed: +107, -80
13 Modified Paths:
/intern/guardedalloc/MEM_guardedalloc.h (+43, -30) (Diff)
/intern/libmv/intern/utildefines.h (+15, -3) (Diff)
/intern/opencolorio/ocio_impl.cc (+21, -21) (Diff)
/intern/opensubdiv/internal/evaluator/evaluator_capi.cc (+2, -2) (Diff)
/intern/opensubdiv/internal/topology/topology_refiner_capi.cc (+2, -2) (Diff)
/source/blender/blenkernel/intern/volume.cc (+7, -6) (Diff)
/source/blender/blenlib/intern/task_scheduler.cc (+3, -3) (Diff)
/source/blender/editors/asset/intern/asset_indexer.cc (+3, -4) (Diff)
/source/blender/editors/asset/intern/asset_temp_id_consumer.cc (+3, -2) (Diff)
/source/blender/editors/interface/interface_view.cc (+2, -2) (Diff)
/source/blender/editors/space_file/asset_catalog_tree_view.cc (+3, -2) (Diff)
/source/blender/editors/space_node/node_geometry_attribute_search.cc (+2, -2) (Diff)
/source/blender/modifiers/intern/MOD_nodes.cc (+1, -1) (Diff)
/intern/libmv/intern/utildefines.h (+15, -3) (Diff)
/intern/opencolorio/ocio_impl.cc (+21, -21) (Diff)
/intern/opensubdiv/internal/evaluator/evaluator_capi.cc (+2, -2) (Diff)
/intern/opensubdiv/internal/topology/topology_refiner_capi.cc (+2, -2) (Diff)
/source/blender/blenkernel/intern/volume.cc (+7, -6) (Diff)
/source/blender/blenlib/intern/task_scheduler.cc (+3, -3) (Diff)
/source/blender/editors/asset/intern/asset_indexer.cc (+3, -4) (Diff)
/source/blender/editors/asset/intern/asset_temp_id_consumer.cc (+3, -2) (Diff)
/source/blender/editors/interface/interface_view.cc (+2, -2) (Diff)
/source/blender/editors/space_file/asset_catalog_tree_view.cc (+3, -2) (Diff)
/source/blender/editors/space_node/node_geometry_attribute_search.cc (+2, -2) (Diff)
/source/blender/modifiers/intern/MOD_nodes.cc (+1, -1) (Diff)