Commit Graph

309 Commits

Author SHA1 Message Date
Brecht Van Lommel
d6570fcaed Cleanup: compiler warnings 2020-08-12 12:15:01 +02:00
Campbell Barton
7f15120e9c Cleanup: GCC warning in guardedalloc_overflow_test 2020-08-11 13:22:59 +10:00
Brecht Van Lommel
53d203dea8 Tests: move remaining gtests into their own module folders
And make them part of the blender_test runner. The one exception is blenlib
performance tests, which we don't want to run by default. They remain in their
own executable.

Differential Revision: https://developer.blender.org/D8498
2020-08-10 18:14:00 +02:00
Campbell Barton
586a308467 Cleanup: remove redundant return parenthesis 2020-08-08 13:37:55 +10:00
Ray Molenkamp
994ab8985b Cleanup: Fix reported clang-tidy code-style issues.
This resolves `error: statement should be inside braces` in some
windows specific code that previously was unchecked by clang-tidy.
2020-08-07 14:53:42 -06:00
c04088fed1 Cleanup: Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule. This should be the final commit of the series of commits that
addresses this particular rule.

No functional changes.
2020-08-07 13:38:07 +02:00
Campbell Barton
901ee66ea1 Cleanup: use term init instead of initialize/initialise
The abbreviation 'init' is brief, unambiguous and already used
in thousands of places, also initialize is often accidentally
written with British spelling.
2020-08-01 13:51:05 +10:00
Jacques Lucke
89f4191a53 Allocator: fix build error with -Werror=format-security 2020-07-25 15:10:24 +02:00
Jacques Lucke
236ca8fbe8 Allocator: make leak detection work with static variables
When definining static variables that own memory, you should
use the "construct on first use" idiom. Otherwise, you'll get
a warning when Blender exits.

More details are provided in D8354.

Differential Revision: https://developer.blender.org/D8354
2020-07-24 12:26:11 +02:00
Campbell Barton
a148c4676b Cleanup: spelling 2020-07-10 16:04:09 +10:00
Jacques Lucke
02cd159539 Cleanup: add comment explaining operator delete 2020-07-07 12:31:25 +02:00
Jacques Lucke
5761cb9ee2 Guarded Allocator: add missing operator delete
This resolves warning C4291 on windows.
2020-07-07 11:52:45 +02:00
Sebastian Parborg
d7dbf90a02 Clang-tidy: Enable braces-around-statements warning 2020-07-03 21:23:33 +02:00
Hans Goudey
19ff145e66 Clang-Tidy: Enable readability-redundant-control-flow 2020-07-03 09:41:55 -04:00
Sergey Sharybin
468adfa4fd Guarded allocator: Override placement new operator
Allows to in-place construct objects which are using guarded allocator.
2020-07-03 12:30:20 +02:00
Campbell Barton
074929d1c5 MEM_guardedalloc: allow freeing const arrays with MEM_SAFE_FREE
'const' arrays couldn't use this macro with GNUC.
2020-06-24 22:13:27 +10:00
Brecht Van Lommel
4f622c9a08 Fix Windows build after recent guardedalloc changes 2020-05-20 00:32:17 +02:00
Brecht Van Lommel
183ba284f2 Cleanup: make guarded memory allocation always thread safe
Previously this would be enabled when threads were used, but threads are now
basically always in use so there is no point. Further, this is only needed for
guarded allocation with --debug-memory which is not performance critical.
2020-05-20 01:03:05 +02:00
Brecht Van Lommel
120e9924c1 Cleanup: remove legacy mmap memory allocation for 32 bit
This helped to go beyond the 4GB limit, but is no longer relevant for 64 bit.
2020-05-20 00:57:41 +02:00
Jacques Lucke
975c45df9a Cleanup: don't use deprecated exception specifications
Usage of exception specifications is discouraged by the C++ core guidelines.
2020-05-14 11:24:50 +02:00
Dalai Felinto
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
James Fulop
6ab359e525 Fix potential crash in guarded alloc stats, when there are no allocations
This was found with static analysis warnings in Visual Studio 2019.

Differential Revision: https://developer.blender.org/D6564
2020-01-31 13:01:07 +01:00
c76a8f65b7 Memory: add OBJECT_GUARDED_SAFE_DELETE like MEM_SAFE_FREE 2020-01-27 12:22:01 +01:00
1107af1abb Fix OBJECT_GUARDED_FREE compiler error when type is in namespace 2020-01-27 12:22:01 +01:00
Jacques Lucke
9c9ea37770 Fix: Use a minimal alignment of 8 in MEM_lockfree_mallocN_aligned
`posix_memalign` requires the `alignment` to be at least `sizeof(void *)`.
Previously, `MEM_mallocN_aligned` would simply return `NULL` if a too small
`alignment` was used. This was an OS specific issue.

The solution is to use a minimal alignment of `8` for all aligned allocations.
The unit tests have been extended to test more possible alignments (some
of which were broken before).

Reviewers: brecht

Differential Revision: https://developer.blender.org/D6660
2020-01-23 14:21:48 +01:00
64cd9a079b Fix T70952: EXR files bigger than 2GB don't open on Windows 2019-11-06 17:16:46 +01:00
Campbell Barton
312075e688 CMake: add missing headers, use space before comments 2019-10-29 01:33:44 +11:00
Stefan Werner
ca76ecfa0e Cleanup: clang-format 2019-09-14 09:26:51 +02:00
Stefan Werner
c80564ef9f macOS: Enabled posix_memalign() like on other Unix platforms. 2019-09-13 22:49:26 +02:00
Jacques Lucke
f2cab8267f Memory: Fix guarded aligned malloc with small alignment
When calling `MEM_guarded_mallocN_aligned` with an alignment of 4,
a pointer that was returned that is 4 byte but not 8 byte aligned.
When freeing this pointer, `MEM_guarded_freeN` thinks that it is an
illegal pointer, because it asserts that `((intptr_t)memh) & 0x7 == 0`.

The fix is to always use at least 8 byte alignment.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5529
2019-08-20 09:45:47 +02:00
Campbell Barton
177a0ca131 Cleanup: comments (long lines) in various intern/ libs 2019-05-01 21:00:56 +10:00
Campbell Barton
a54bdd76cb ClangFormat: format '#if 0' code
Previous cleanups didn't account for space after '#'.
2019-04-17 08:52:59 +02:00
Campbell Barton
108045faa0 ClangFormat: format '#if 0' code in intern/ 2019-04-17 08:17:13 +02:00
Campbell Barton
e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton
47adab4f99 CMake: prepare for BLENDER_SORTED_LIBS removal
No functional change, this adds LIB definition and args to cmake files.
Without this it's difficult to migrate away from 'BLENDER_SORTED_LIBS'
since there are many platforms/configurations that could break when
changing linking order.

Manually add and enable WITHOUT_SORTED_LIBS to try building
without sorted libs (currently fails since all variables are empty).
This check will eventually be removed.

See T46725.
2019-04-14 15:37:24 +02:00
Campbell Barton
de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton
3316853323 Cleanup: conform headers to have license first
Also remove doxy comments for licenses and add missing GPL header.
2019-02-18 08:22:11 +11:00
Campbell Barton
eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton
ab5e69e660 Cleanup: remove contributors for CMake files
Following removal from C source code.

See: 8c68ed6df16d8893
2019-02-05 09:10:32 +11:00
Campbell Barton
4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton
65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton
4d29312c66 Cleanup: trailing space guardedalloc & memutil 2019-01-24 16:22:44 +11:00
Campbell Barton
302970b7a5 MSVC: remove compiler __func__ define
No longer needed and exposes a bug in clang-format see: D4185
2019-01-11 09:22:21 +11:00
d05b9e0a2e Fix build with older CMake versions that we still need to support. 2018-10-03 12:55:43 +02:00
d2da3af073 Fix T54287: memory not freed after rendering on Linux.
With new jemalloc versions memory allocated by threads that then become
inactive is not longer automatically freed. Instead we have to enable a
background thread to do it.

Some testing is needed to find out of this is sufficient, because the
background thread only runs periodically.
2018-10-03 12:09:31 +02:00
Campbell Barton
103a31f712 Fix incorrect size in aligned lockfree realloc
Thanks to @alikendarfen for finding.
2018-05-23 07:24:57 +02:00
Campbell Barton
28c20fc393 Memory allocator: use lockfree calls internally
Was already used in some areas.
2018-05-22 08:45:47 +02:00
Sergey Sharybin
a5bb918392 Memory allocator: Clarify consistency check function
Also make it to return truth when everything is good and
false otherwise.
2018-03-20 16:51:33 +01:00
a6700362c7 Memory: add MEM_malloc_arrayN() function to protect against overflow.
Differential Revision: https://developer.blender.org/D3002
2018-01-17 19:59:47 +01:00
Campbell Barton
28d2148b09 Haiku OS Support
D2860 by @miqlas

Even though Haiku is a niche OS, only minor changes are needed.
2017-11-30 18:05:21 +11:00