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:02:20 +02:00
2023-12-08 13:28:13 +11:00
2025-07-10 12:48:33 +10:00

Blender

Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing, motion tracking and video editing.

Blender screenshot

Project Pages

Development

License

Blender as a whole is licensed under the GNU General Public License, Version 3. Individual files may have a different but compatible license.

See blender.org/about/license for details.

Description
No description provided
Readme 841 MiB
Languages
C++ 78%
Python 14.9%
C 2.9%
GLSL 1.9%
CMake 1.2%
Other 0.9%