Commit Graph

98 Commits

Author SHA1 Message Date
bb6765f28f Cleanup: spelling 2021-03-18 09:36:44 +11:00
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
a16e4652e3 Fix integer overflow in BLI_mempool_as_arrayN()
`(size_t)(int * int)` will actually cast overflown integer to size_t,
which isn't what was intended here. Correct thing would be to cast
in the following manner `(size_t)int * int`.

In this particular case can as well use function which is designed to
allocate an array of memory without overflow.
2020-03-06 15:35:52 +01:00
760dbd1cbf Cleanup: misc spelling fixes
T68035 by @luzpaz
2019-08-01 14:02:41 +10:00
cda4cd0705 Cleanup: comments (long lines) in blenlib 2019-04-22 06:30:08 +10:00
41d4a19865 ClangFormat: format '#if 0' code in source/ 2019-04-17 08:24:14 +02:00
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
b5d1e0ad1e Cleanup: spelling 2019-04-10 00:38:47 +10:00
b8bb2bb960 Cleanup: warning in release builds 2019-03-06 02:49:30 +11:00
10d41e48b8 Fix BLI_mempool incorrect slop-space calculation
Also ensure elements fit evenly into the chunk size
causing allocations to be slightly smaller in some cases.

In own tests reduces overall memory use by about ~4.5%
for high poly meshes in edit-mode.
2019-03-02 20:31:31 +11:00
cf75aea218 Cleanup: code style & comments 2019-03-02 18:36:42 +11:00
e5b6020ffc Cleanup: remove unused define
There is no reason to keep the option for separate allocations,
it makes code harder to follow.
2019-03-02 18:36:42 +11:00
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
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
4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
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
e757c4a3be Cleanup: use colon separator after parameter
Helps separate variable names from descriptive text.
Was already used in some parts of the code,
double space and dashes were used elsewhere.
2018-12-12 12:50:58 +11:00
ccdacf1c9b Cleanup: use '_len' instead of '_size' w/ BLI API
- When returning the number of items in a collection use BLI_*_len()
- Keep _size() for size in bytes.
- Keep _count() for data structures that don't store length
  (hint this isn't a simple getter).

See P611 to apply instead of manually resolving conflicts.
2018-02-15 23:39:08 +11:00
b63442e0b6 Minor cleanup for own recent commits. 2017-11-23 22:43:11 +01:00
b84e6dfee4 Add ability to use more than one mempool iterator simultaneously.
This will allow threaded tasks to 'consume' all mempool items in
parallel tasks, each one working on a whole chunk at once (to reduce
concurrency managing overhead).
2017-11-23 21:12:00 +01:00
8ac69ff9dc Cleanup: use uint type in BLI 2017-10-28 17:48:45 +11:00
d733826708 Fix T48614: Blender from buildbot crash when Separate selection in this particular scene.
Regression from recent rB2c5dc66d5effd4072f438afb, if last item of last chunk of a mempool was valid,
it would not be returned by mempool iterator step, which would always return NULL in that case.
2016-06-09 17:53:51 +02:00
2c5dc66d5e Optimize mempool iteration
Around ~10% improvement in own tests.
2016-06-02 00:07:18 +10:00
aedeca7d1c BLI_mempool: Use an 'odd' FREEWORD for big/little endian
This also changes freeword to an intptr_t to ensure
not only the first 4 bits of a pointer are tested on 64bit systems.
2016-06-01 02:54:47 +10:00
62c8f46ab6 Docs: comment functions in BLI & Py API 2015-08-05 02:09:03 +10:00
b707b07c5b Fix mempool bottleneck alloc & freeing a single item
Would continuously reinitialize the first chunk of the mempool,
now check for at least 2 blocks.
2014-06-08 23:09:30 +10:00
f700a13eb5 Revert "Mempool: simplify memory chunk list building"
This reverts commit c82371fc06.

Caused regression in iterator
2014-04-10 11:35:17 +10:00
82628a6b0e Code cleanup: use struct type for mempool & style edits 2014-04-10 06:49:25 +10:00
c82371fc06 Mempool: simplify memory chunk list building 2014-04-08 13:41:57 +10:00
412826a504 Mempool: delay allocating an initial chunk, its not always used 2014-04-08 12:58:56 +10:00
5c5d643938 Mempool: use define for used freeword and correct define 2014-04-07 12:52:23 +10:00
13d90ab8f7 Mempool: minor optimization to building free pointer list 2014-04-07 12:38:32 +10:00
aee82b4b2c Mempool: fix own error in recent commit
chunks must be added in order for iteration.
2014-04-07 12:38:32 +10:00
19b7bb5975 Optimize mempool: round chunk size to powers of 2, account for slop-space
This helps to reduce memory fragmentation.
2014-04-05 12:14:05 +11:00
af59ee340f Mempool: remove BLI_MEMPOOL_SYSMALLOC, MEM_* allocs are more efficient now 2014-04-05 12:14:05 +11:00
70353f833a Optimize mempool: replace double linked list with single for memory chunks 2014-04-05 09:49:13 +11:00
7cb90a611f Optimization for mempool initial chunk allocation
Almost all pools allocated 2 chunks on initialization,
every element needed to be added to the free-list which
would never be used for small pools.

Now allocate only one, gives minor speedup for some bmesh operations.
2014-04-04 21:25:08 +11:00
b3afbcab8f ListBase API: add utility api funcs for clearing and checking empty 2014-02-08 06:24:05 +11:00
737e51cb21 Mempool/Memarena: hint for unlikely conditions 2013-12-10 21:28:52 +11:00
c005fb407b Util-defines: avoid multiple calculation/access for MIN/MAX macros 2013-12-08 17:29:22 +11:00
7c8c49a34a style cleanup 2013-10-21 23:35:08 +00:00
6631d4ddd5 Build fix (issue could happen with scons,reported by ebrain on IRC, thanks).
Var declared in an #ifdef DEBUG, but used in an #ifndef NDEBUG…
2013-10-07 07:39:58 +00:00
48013e8a9c more corrections to valgrind hinting. 2013-10-05 04:59:43 +00:00
2621d77f39 use valgrind hints for memarena for better debugging info when using valgrind.
also quiet a false positive in BLI_mempool_free().
2013-10-05 04:38:08 +00:00
f5eb880358 freeing mempool elements now fills freed memory with --debug for debug builds. 2013-10-03 14:44:33 +00:00
9b1be7ce93 add cmake option WITH_MEM_VALGRIND, helps to track down errors with mempool use which sometimes only show up as bugs in very rare cases (because even though the element is freed, the chunk is still allocated). 2013-10-03 12:22:44 +00:00
2dc988df8c reorder BLI_strict_flags.h include so its not conflicting with stdio.h on apple. 2013-09-03 04:39:12 +00:00
1ea9f88ff9 warning cleanup: correct some odd returns and quiet strict flag warnings on some systems. 2013-09-02 17:59:04 +00:00
2924a02a35 move strict compiler checks into a header so its easier to manage in one place (pragmas were copied around).
also enable more strict warnings for BLF (which had some incorrect casts).
2013-09-01 00:46:04 +00:00
8e46cf637c tweak mempool loop comparisons when we know there is no chance for skipping past the last value.
also correct typo.
2013-08-31 02:12:31 +00:00