Blender Git Commit Log

Git Commits -> Revision 2aff451

Revision 2aff451 by Jacques Lucke (master)
August 19, 2020, 14:44 (GMT)
BLI: improve exception safety of Vector, Array and Stack

Using C++ exceptions in Blender is difficult, due to the large
number of C functions in the call stack. However, C++ data
structures in blenlib should at least try to be exception safe,
so that they can be used if someone wants to use exceptions
in some isolated area.

This patch improves the exception safety of the Vector, Array
and Stack data structure. This is mainly achieved by reordering
some lines and doing some explicit exception handling.
I don't expect performance of common operations to be affected
by this change.

The three containers are supposed to provide at least the
basic exception guarantee for most methods (except for e.g.
`*_unchecked` methods). So, resources should not leak when
the contained type throws an exception.

I also added new unit tests that test the exception handling
in various cases.

Commit Details:

Full Hash: 2aff45146f1464ba8899368ad004522cb6a1a98c
Parent Commit: aeaf2b0
Lines Changed: +445, -122

1 Added Path:

/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh (+60, -0) (View)

9 Modified Paths:

/source/blender/blenlib/BLI_array.hh (+32, -36) (Diff)
/source/blender/blenlib/BLI_memory_utils.hh (+55, -1) (Diff)
/source/blender/blenlib/BLI_stack.hh (+59, -36) (Diff)
/source/blender/blenlib/BLI_vector.hh (+56, -49) (Diff)
/source/blender/blenlib/CMakeLists.txt (+2, -0) (Diff)
/source/blender/blenlib/tests/BLI_array_test.cc (+39, -0) (Diff)
/source/blender/blenlib/tests/BLI_memory_utils_test.cc (+2, -0) (Diff)
/source/blender/blenlib/tests/BLI_stack_cxx_test.cc (+56, -0) (Diff)
/source/blender/blenlib/tests/BLI_vector_test.cc (+84, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021