Cleanup: python: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on allocated type possible. This is a serious source of annoyance (and crashes) when making some low-level structs non-trivial, as tracking down all usages of these structs in higher-level other structs and their allocation is... really painful. MEM_[cm]allocN<T> templates on the other hand do check that the given type is trivial, at build time (static assert), which makes such issue... trivial to catch. NOTE: New code should strive to use MEM_new (i.e. allocation and construction) as much as possible, even for trivial PoD types. Pull Request: https://projects.blender.org/blender/blender/pulls/135852
This commit is contained in:
committed by
Bastien Montagne
parent
9f697c7cc6
commit
bb89c89e7f
@@ -65,7 +65,7 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject * /*self*/, PyObject *args)
|
||||
}
|
||||
|
||||
if (len) {
|
||||
float *weights = static_cast<float *>(MEM_mallocN(sizeof(float) * len, __func__));
|
||||
float *weights = MEM_malloc_arrayN<float>(size_t(len), __func__);
|
||||
|
||||
interp_weights_poly_v3(weights, vecs, len, fp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user