Blender Git Commit Log

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:

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/ (+21, -21) (Diff)
/intern/opensubdiv/internal/evaluator/ (+2, -2) (Diff)
/intern/opensubdiv/internal/topology/ (+2, -2) (Diff)
/source/blender/blenkernel/intern/ (+7, -6) (Diff)
/source/blender/blenlib/intern/ (+3, -3) (Diff)
/source/blender/editors/asset/intern/ (+3, -4) (Diff)
/source/blender/editors/asset/intern/ (+3, -2) (Diff)
/source/blender/editors/interface/ (+2, -2) (Diff)
/source/blender/editors/space_file/ (+3, -2) (Diff)
/source/blender/editors/space_node/ (+2, -2) (Diff)
/source/blender/modifiers/intern/ (+1, -1) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021