Files
test/intern
Bastien Montagne 307d0de26e Allocator: Add MEM_new_for_free to allow construction of almost-trivial types.
The data constructed by this call remains in the 'C-alloc' realm, i.e.
it can be `MEM_dupallocN`'ed, and `MEM_freeN`'ed.

This is intended as a temporary API only, to facilitate transition to
full C++ handling of data in Blender. It's primary target is to allow
pseudo-POD types to use default values for their members. See e.g.
!134531.

Unlike !143827 and !138829, it does not change the current rule (`new`
must be paired with `delete`, and `alloc` must be paired with `free`).

Instead, it defines an explicit and temporary API to allow a very
limited form of construction to happen on C-allocated data, provided
that the type is default-constructible, and remains trivial after
construction.

### Notes
* The new API is purposely as restrictive as possible, trying to
  only allow the current known needs (init with default member values).
  This can easily be extended if needed.
* To try to stay as close as malloc/calloc behavior as possible, and
  avoid the 'zero-initialization' gotcha, it does not use
  value-initialization, but instead default-initialization on zero-
  initialized memory.
  _Ideally it would even not allow any user-defined default constructor,
  but this does not seem simple to detect._

Pull Request: https://projects.blender.org/blender/blender/pulls/144141
2025-08-11 14:56:11 +02:00
..
2025-08-11 12:39:37 +02:00
2025-07-05 08:50:25 +10:00