Commit Graph

15 Commits

Author SHA1 Message Date
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Bastien Montagne
00f406c34c Refactor: BLI: Re-implement BLI_string_split_name_number in C++.
Allows to use this code from C++ code/data, without duplicating strings
to char arrays. C-compatible API is kept as a wrapper around the new
implementation.

No behavioral change is expected from this commit.

Part of !135199.
2025-02-28 17:21:59 +01:00
Brecht Van Lommel
6b6cd3307b Cleanup: Various clang-tidy warnings in blenlib
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Campbell Barton
4f5f0040c0 Cleanup: back-tick quote file extensions in code-comments 2024-05-04 15:06:46 +10:00
Campbell Barton
962d2ca6a6 Cleanup: use a const ListBase argument to BLI_uniquename
The list-base isn't manipulated, only the link argument.
2024-04-11 17:44:27 +10:00
Campbell Barton
3f8cd44485 Cleanup: move BLI_strict_flags.h last, not that it should be kept last
Also add a note in the header why it should be kept last.
2024-02-14 13:40:31 +11:00
Hans Goudey
21407901f8 Cleanup: Various clang tidy changes 2024-01-19 12:08:48 -05:00
Campbell Barton
375c217ea0 Cleanup: apply clang-tidy modernize-deprecated-headers 2024-01-08 11:32:49 +11:00
Campbell Barton
aaf05c2497 Cleanup: various C++ changes (use nullptr, function style casts) 2023-11-07 11:35:16 +11:00
Campbell Barton
d31c61edee Cleanup: spelling in comments 2023-10-27 12:13:48 +11:00
Julian Eisel
7654898c18 Fix compile error on GCC
Was getting a compile error after 7afa5aaa59.
2023-10-24 12:07:17 +02:00
Sergey Sharybin
7afa5aaa59 BLI: Add std::string variant of BLI_uniquename_cb
Allows to ensure unique name for cases when name is a dynamically
sized string.

Pull Request: https://projects.blender.org/blender/blender/pulls/114052
2023-10-24 11:35:52 +02:00
Campbell Barton
2864c20302 Cleanup: various C++ changes (use nullptr, function style casts) 2023-10-21 21:17:57 +11:00
Sergey Sharybin
85c557ffa2 Cleanup: Rename BLI_string_utils.h to BLI_string_utils.hh
All users of it are now C++, which opens doors to add C++ to the
public API.
2023-10-20 10:27:26 +02:00
Sergey Sharybin
6bbf7649d0 Cleanup: Convert string_utils to C++
Pretty much as-is conversion, so it is a C code in a C++ file.
2023-10-20 10:27:26 +02:00