diff options
author | Antonis Ryakiotakis <kalast@gmail.com> | 2022-02-07 21:37:15 +0300 |
---|---|---|
committer | Antonis Ryakiotakis <kalast@gmail.com> | 2022-02-07 21:37:15 +0300 |
commit | d8c05502272990173381bfd2590884bbc95aa5f5 (patch) | |
tree | 8bd65efacbe6484b838d4550597d0f4a54ddddd9 /intern/guardedalloc/MEM_guardedalloc.h | |
parent | b64d551f3b2fa409b4eeefb641fc581eb6cd0bd6 (diff) | |
parent | fe1816f67fbc6aaf383ec77847d668367335d093 (diff) |
Merge branch 'master' into KTX_supportKTX_support
Diffstat (limited to 'intern/guardedalloc/MEM_guardedalloc.h')
-rw-r--r-- | intern/guardedalloc/MEM_guardedalloc.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 8a20323dcfc..dccb7a32139 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -39,8 +39,8 @@ * second intern/ module with MEM_ prefix, for use in c++. * * \subsection memdependencies Dependencies - * - stdlib - * - stdio + * - `stdlib` + * - `stdio` * * \subsection memdocs API Documentation * See \ref MEM_guardedalloc.h @@ -268,6 +268,12 @@ void MEM_use_guarded_allocator(void); * Allocate new memory for and constructs an object of type #T. * #MEM_delete should be used to delete the object. Just calling #MEM_freeN is not enough when #T * is not a trivial type. + * + * Note that when no arguments are passed, C++ will do recursive member-wise value initialization. + * That is because C++ differentiates between creating an object with `T` (default initialization) + * and `T()` (value initialization), whereby this function does the latter. Value initialization + * rules are complex, but for C-style structs, memory will be zero-initialized. So this doesn't + * match a `malloc()`, but a `calloc()` call in this case. See https://stackoverflow.com/a/4982720. */ template<typename T, typename... Args> inline T *MEM_new(const char *allocation_name, Args &&...args) |