[Bf-blender-cvs] [c14fa10d565] sculpt-dev: Sculpt: Fix gcc compile error
Joseph Eagar
noreply at git.blender.org
Sun Oct 17 13:26:17 CEST 2021
Commit: c14fa10d56544e85b2af42e9a38f74e85521a7e3
Author: Joseph Eagar
Date: Sun Oct 17 04:25:55 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBc14fa10d56544e85b2af42e9a38f74e85521a7e3
Sculpt: Fix gcc compile error
===================================================================
M source/blender/blenlib/intern/BLI_mempool.c
===================================================================
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index d04e986f6f3..c87c99ac57c 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -17,17 +17,17 @@
* All rights reserved.
*/
-/** \file
- * \ingroup bli
- *
- * Simple, fast memory allocator for allocating many elements of the same size.
- *
- * Supports:
- *
- * - Freeing chunks.
- * - Iterating over allocated chunks
- * (optionally when using the #BLI_MEMPOOL_ALLOW_ITER flag).
- */
+ /** \file
+ * \ingroup bli
+ *
+ * Simple, fast memory allocator for allocating many elements of the same size.
+ *
+ * Supports:
+ *
+ * - Freeing chunks.
+ * - Iterating over allocated chunks
+ * (optionally when using the #BLI_MEMPOOL_ALLOW_ITER flag).
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -57,7 +57,7 @@
# define POISON_REDZONE_SIZE 0
#endif
-/* NOTE: copied from BLO_blend_defs.h, don't use here because we're in BLI. */
+ /* NOTE: copied from BLO_blend_defs.h, don't use here because we're in BLI. */
#ifdef __BIG_ENDIAN__
/* Big Endian */
# define MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d))
@@ -82,15 +82,15 @@
((sizeof(void *) > sizeof(int32_t)) ? MAKE_ID_8('e', 'e', 'r', 'f', 'f', 'r', 'e', 'e') : \
MAKE_ID('e', 'f', 'f', 'e'))
-/**
- * The 'used' word just needs to be set to something besides FREEWORD.
- */
+ /**
+ * The 'used' word just needs to be set to something besides FREEWORD.
+ */
#define USEDWORD MAKE_ID('u', 's', 'e', 'd')
-/* Currently totalloc isn't used. */
-// #define USE_TOTALLOC
+ /* Currently totalloc isn't used. */
+ // #define USE_TOTALLOC
-/* optimize pool size */
+ /* optimize pool size */
#define USE_CHUNK_POW2
#ifndef NDEBUG
@@ -200,7 +200,7 @@ static void mempool_update_chunktable(BLI_mempool *pool)
MEM_SAFE_FREE(pool->chunktable);
pool->chunktable = (BLI_mempool_chunk **)MEM_mallocN(
- sizeof(pool->chunktable) * (size_t)pool->totchunk, "mempool chunktable");
+ sizeof(pool->chunktable) * (size_t)pool->totchunk,"mempool chunktable");
int i = 0;
chunk = pool->chunks;
@@ -211,7 +211,7 @@ static void mempool_update_chunktable(BLI_mempool *pool)
}
}
-BLI_INLINE BLI_mempool_chunk *mempool_chunk_find(BLI_mempool_chunk *head, uint index)
+BLI_INLINE BLI_mempool_chunk *mempool_chunk_find(BLI_mempool_chunk *head,uint index)
{
while (index-- && head) {
head = head->next;
@@ -225,14 +225,14 @@ BLI_INLINE BLI_mempool_chunk *mempool_chunk_find(BLI_mempool_chunk *head, uint i
* \note for small pools 1 is a good default, the elements need to be initialized,
* adding overhead on creation which is redundant if they aren't used.
*/
-BLI_INLINE uint mempool_maxchunks(const uint totelem, const uint pchunk)
+BLI_INLINE uint mempool_maxchunks(const uint totelem,const uint pchunk)
{
return (totelem <= pchunk) ? 1 : ((totelem / pchunk) + 1);
}
static BLI_mempool_chunk *mempool_chunk_alloc(BLI_mempool *pool)
{
- return BLI_asan_safe_malloc(sizeof(BLI_mempool_chunk) + (size_t)pool->csize, pool->memtag);
+ return BLI_asan_safe_malloc(sizeof(BLI_mempool_chunk) + (size_t)pool->csize,pool->memtag);
}
/**
@@ -245,8 +245,8 @@ static BLI_mempool_chunk *mempool_chunk_alloc(BLI_mempool *pool)
* \return The last chunk,
*/
static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
- BLI_mempool_chunk *mpchunk,
- BLI_freenode *last_tail)
+ BLI_mempool_chunk *mpchunk,
+ BLI_freenode *last_tail)
{
const uint esize = pool->esize;
BLI_freenode *curnode = CHUNK_DATA(mpchunk);
@@ -254,16 +254,16 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
if (pool->flag & BLI_MEMPOOL_RANDOM_ACCESS) {
if (!pool->chunktable ||
- MEM_allocN_len(pool->chunktable) / sizeof(void *) <= (size_t)pool->totchunk) {
+ MEM_allocN_len(pool->chunktable) / sizeof(void *) <= (size_t)pool->totchunk) {
void *old = pool->chunktable;
int size = (int)pool->totchunk + 2;
size += size >> 1;
- pool->chunktable = MEM_mallocN(sizeof(void *) * (size_t)size, "mempool chunktable");
+ pool->chunktable = MEM_mallocN(sizeof(void *) * (size_t)size,"mempool chunktable");
if (old) {
- memcpy(pool->chunktable, old, sizeof(void *) * (size_t)pool->totchunk);
+ memcpy(pool->chunktable,old,sizeof(void *) * (size_t)pool->totchunk);
}
MEM_SAFE_FREE(old);
@@ -275,8 +275,7 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
/* append */
if (pool->chunk_tail) {
pool->chunk_tail->next = mpchunk;
- }
- else {
+ } else {
BLI_assert(pool->chunks == NULL);
pool->chunks = mpchunk;
}
@@ -294,23 +293,22 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
while (j--) {
BLI_freenode *next;
- BLI_asan_unpoison(curnode, pool->esize - POISON_REDZONE_SIZE);
+ BLI_asan_unpoison(curnode,pool->esize - POISON_REDZONE_SIZE);
curnode->next = next = NODE_STEP_NEXT(curnode);
curnode->freeword = FREEWORD;
- BLI_asan_poison(curnode, pool->esize);
+ BLI_asan_poison(curnode,pool->esize);
curnode = next;
}
- }
- else {
+ } else {
while (j--) {
BLI_freenode *next;
- BLI_asan_unpoison(curnode, pool->esize - POISON_REDZONE_SIZE);
+ BLI_asan_unpoison(curnode,pool->esize - POISON_REDZONE_SIZE);
curnode->next = next = NODE_STEP_NEXT(curnode);
- BLI_asan_poison(curnode, pool->esize);
+ BLI_asan_poison(curnode,pool->esize);
curnode = next;
}
@@ -319,15 +317,15 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
/* terminate the list (rewind one)
* will be overwritten if 'curnode' gets passed in again as 'last_tail' */
- BLI_asan_unpoison(curnode, pool->esize - POISON_REDZONE_SIZE);
+ BLI_asan_unpoison(curnode,pool->esize - POISON_REDZONE_SIZE);
BLI_freenode *prev = NODE_STEP_PREV(curnode);
- BLI_asan_poison(curnode, pool->esize);
+ BLI_asan_poison(curnode,pool->esize);
curnode = NODE_STEP_PREV(curnode);
- BLI_asan_unpoison(curnode, pool->esize - POISON_REDZONE_SIZE);
+ BLI_asan_unpoison(curnode,pool->esize - POISON_REDZONE_SIZE);
curnode->next = NULL;
- BLI_asan_poison(curnode, pool->esize);
+ BLI_asan_poison(curnode,pool->esize);
#ifdef USE_TOTALLOC
pool->totalloc += pool->pchunk;
@@ -335,9 +333,9 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
/* final pointer in the previously allocated chunk is wrong */
if (last_tail) {
- BLI_asan_unpoison(last_tail, pool->esize - POISON_REDZONE_SIZE);
+ BLI_asan_unpoison(last_tail,pool->esize - POISON_REDZONE_SIZE);
last_tail->next = CHUNK_DATA(mpchunk);
- BLI_asan_poison(last_tail, pool->esize);
+ BLI_asan_poison(last_tail,pool->esize);
}
return curnode;
@@ -350,14 +348,14 @@ to tasks.
*/
BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
- int totelem,
- const int pchunk,
- void ***r_chunks,
- int *r_totchunk,
- int *r_esize,
- int flag)
+ int totelem,
+ const int pchunk,
+ void ***r_chunks,
+ int *r_totchunk,
+ int *r_esize,
+ int flag)
{
- BLI_mempool *pool = BLI_mempool_create(esize, 0, (uint)pchunk, (uint)flag);
+ BLI_mempool *pool = BLI_mempool_create(esize,0,(uint)pchunk,(uint)flag);
// override pchunk, may not be a power of 2
pool->pchunk = (uint)pchunk;
@@ -365,8 +363,7 @@ BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
if (totelem % pchunk == 0) {
pool->maxchunks = (uint)totelem / (uint)pchunk;
- }
- else {
+ } else {
pool->maxchunks = (uint)totelem / (uint)pchunk + 1;
}
@@ -376,17 +373,17 @@ BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
/* Allocate the actual chunks. */
for (uint i = 0; i < pool->maxchunks; i++) {
BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool);
- last_tail = mempool_chunk_add(pool, mpchunk, last_tail);
+ last_tail = mempool_chunk_add(pool,mpchunk,last_tail);
}
}
void **chunks = MEM_callocN(sizeof(void *) * pool->maxchunks,
- "BLI_mempool_create_for_tasks r_chunks");
+ "BLI_mempool_create_for_tasks r_chunks");
unsigned int totalloc = 0;
*r_totchunk = 0;
- BLI_mempool_chunk *chunk = pool->chunks, *lastchunk = NULL;
+ BLI_mempool_chunk *chunk = pool->chunks,*lastchunk = NULL;
while (chunk) {
lastchunk = chunk;
@@ -419,7 +416,7 @@ BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
char *elem = CHUNK_DATA(lastchunk);
elem += pool->esize * (unsigned int)i;
- BLI_mempool_free(pool, elem);
+ BLI_mempool_free(pool,elem);
totalloc--;
i--;
@@ -444,19 +441,19 @@ BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
return pool;
}
-static void mempool_chunk_free(BLI_mempool_chunk *mpchunk, BLI_mempool *pool)
+static void mempool_chunk_free(BLI_mempool_chunk *mpchunk,BLI_mempool *pool)
{
- BLI_asan_unpoison(mpchunk, sizeof(BLI_mempool_chunk) + pool->esize * pool->csize);
+ BLI_asan_unpoison(mpchunk,sizeof(BLI_mempool_chunk) + pool->esize * pool->csize);
BLI_asan_safe_free(mpchunk);
}
-static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk, BLI_mempool *pool)
+static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk,BLI_mempool *pool)
{
BLI_mempool_chunk *mpchunk_next;
for (; mpchunk; mpchunk = mpchunk_next) {
mpchunk_next = mpchunk->next;
- mempool_chunk_free(mpchunk, pool);
+ mempool_chunk_free(mpchunk,pool);
}
}
@@ -464,32 +461,31 @@ static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk, BLI_mempool *pool
# undef BLI_mempool_create
#endif
-BLI_mempool *BLI_mempool_create(uint esize, uint totelem, uint pchunk, uint flag)
+BLI_mempool *BLI_mempool_create(uin
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list