Cleanup: comments, assert align is a power of two

This commit is contained in:
Campbell Barton 2019-03-02 11:57:39 +11:00
parent b5d87f8028
commit 490a385c81
Notes: blender-bot 2023-02-14 10:18:56 +01:00
Referenced by issue #62622, Blender 2.8 - viewport does not show changes in animated vertex positions without clicking a viewport shading button every time
Referenced by issue #62368, pressing z key to switch between extrusion
Referenced by issue #62354, apply explosion effect results in hard crash
Referenced by issue #62336, object info random to control random colours ( colour ramp )  of particle system   not working in eevee
Referenced by issue #62290, strange sculpting bug with multires , only updates when ovelay tab is turned off
Referenced by issue #62291, strange sculpting bug with multires , only updates when ovelay tab is turned on
Referenced by issue #62292, multires + sculpt does not update when object is set to smooth shading and viewport overlay is turned off
Referenced by issue #62160, Bone naming issue after using "Flip Names" command.
Referenced by issue #62140, line segment disappears when using extrude of predefined grease pencil line stroke
Referenced by issue #62141, zero length or missing line segment with predefined grease pencil line stroke
Referenced by issue #62142, 2 incorrect line segments with predefined grease pencil line stroke
Referenced by issue #62125, snapping not working if invisible object is between you and the target
Referenced by issue #62111, Blender hangs switching to Edit Mode with Material Panel visible
Referenced by issue #62112, Blender miscounts object faces
Referenced by issue #62030, Wirefame , random crash
Referenced by issue #61886, Blender crashes when creating new file using shortcut Cntrl N
1 changed files with 10 additions and 10 deletions

View File

@ -15,12 +15,11 @@
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
* Efficient memory allocation for lots of similar small chunks.
*/
/** \file
* \ingroup bli
* \brief Memory arena ADT.
* \brief Efficient memory allocation for many small chunks.
* \section aboutmemarena Memory Arena
*
* Memory arena's are commonly used when the program
@ -54,8 +53,8 @@
#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
# include "sanitizer/asan_interface.h"
#else
# define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
# define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
# define ASAN_POISON_MEMORY_REGION(addr, size) UNUSED_VARS(addr, size)
# define ASAN_UNPOISON_MEMORY_REGION(addr, size) UNUSED_VARS(addr, size)
#endif
struct MemBuf {
@ -107,7 +106,9 @@ void BLI_memarena_use_malloc(MemArena *ma)
void BLI_memarena_use_align(struct MemArena *ma, const size_t align)
{
/* align should be a power of two */
/* Align must be a power of two. */
BLI_assert((align & (align - 1)) == 0);
ma->align = align;
}
@ -120,10 +121,10 @@ void BLI_memarena_free(MemArena *ma)
MEM_freeN(ma);
}
/* amt must be power of two */
/** Pad num up by \a amt (must be power of two). */
#define PADUP(num, amt) (((num) + ((amt) - 1)) & ~((amt) - 1))
/* align alloc'ed memory (needed if align > 8) */
/** Align alloc'ed memory (needed if `align > 8`). */
static void memarena_curbuf_align(MemArena *ma)
{
unsigned char *tmp;
@ -137,8 +138,7 @@ void *BLI_memarena_alloc(MemArena *ma, size_t size)
{
void *ptr;
/* ensure proper alignment by rounding
* size up to multiple of 8 */
/* Ensure proper alignment by rounding size up to multiple of 8. */
size = PADUP(size, ma->align);
if (UNLIKELY(size > ma->cursize)) {
@ -174,7 +174,7 @@ void *BLI_memarena_calloc(MemArena *ma, size_t size)
{
void *ptr;
/* no need to use this function call if we're calloc'ing by default */
/* No need to use this function call if we're calloc'ing by default. */
BLI_assert(ma->use_calloc == false);
ptr = BLI_memarena_alloc(ma, size);