Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Fix review comments.

Co-authored-by: Pavel Kumbrasev <pavel.kumbrasev@intel.com>
  • Loading branch information
sarathnandu and pavelkumbrasev committed Mar 28, 2023
1 parent daf267e commit f6aee25
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions cmake/compilers/MSVC.cmake
Expand Up @@ -37,8 +37,7 @@ set(TBB_COMMON_COMPILE_FLAGS /volatile:iso /FS /EHsc)

set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /DYNAMICBASE /NXCOMPAT)

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
# 32 bits
if (TBB_ARCH EQUAL 32)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /SAFESEH )
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/tbbmalloc/Customize.h
Expand Up @@ -48,7 +48,7 @@
#endif

inline intptr_t BitScanRev(uintptr_t x) {
return !x? -1 : static_cast<intptr_t>(tbb::detail::log2(x));
return x == 0 ? -1 : static_cast<intptr_t>(tbb::detail::log2(x));
}

template<typename T>
Expand Down
6 changes: 3 additions & 3 deletions src/tbbmalloc/backref.cpp
Expand Up @@ -42,13 +42,13 @@ struct BackRefBlock : public BlockI {
nextForUse(nullptr), bumpPtr((FreeObject*)((uintptr_t)blockToUse + slabSize - sizeof(void*))),
freeList(nullptr), nextRawMemBlock(nullptr), allocatedCount(0), myNum(num),
addedToForUse(false) {
memset(static_cast<void *>(&blockMutex), 0, sizeof(MallocMutex));
memset(static_cast<void*>(&blockMutex), 0, sizeof(MallocMutex));

MALLOC_ASSERT(!(num >> CHAR_BIT*sizeof(BackRefIdx::main_t)),
"index in BackRefMain must fit to BackRefIdx::main");
}
// clean all but header
void zeroSet() { memset(static_cast<void *>(this+1), 0, BackRefBlock::bytes-sizeof(BackRefBlock)); }
void zeroSet() { memset(static_cast<void*>(this+1), 0, BackRefBlock::bytes-sizeof(BackRefBlock)); }
static const int bytes = slabSize;
};

Expand Down Expand Up @@ -106,7 +106,7 @@ bool initBackRefMain(Backend *backend)
main->allRawMemBlocks = nullptr;
main->rawMemUsed = rawMemUsed;
main->lastUsed = -1;
memset(static_cast<void *>(&main->requestNewSpaceMutex), 0, sizeof(MallocMutex));
memset(static_cast<void*>(&main->requestNewSpaceMutex), 0, sizeof(MallocMutex));
for (int i=0; i<BackRefMain::leaves; i++) {
BackRefBlock *bl = (BackRefBlock*)((uintptr_t)main + BackRefMain::bytes + i*BackRefBlock::bytes);
bl->zeroSet();
Expand Down
4 changes: 2 additions & 2 deletions src/tbbmalloc/frontend.cpp
Expand Up @@ -928,7 +928,7 @@ static MallocMutex publicFreeListLock; // lock for changes of publicFreeList
LifoList::LifoList( ) : top(nullptr)
{
// MallocMutex assumes zero initialization
memset(static_cast<void *>(&lock), 0, sizeof(MallocMutex));
memset(static_cast<void*>(&lock), 0, sizeof(MallocMutex));
}

void LifoList::push(Block *block)
Expand Down Expand Up @@ -2718,7 +2718,7 @@ rml::MemPoolError pool_create_v1(intptr_t pool_id, const MemPoolPolicy *policy,
*pool = nullptr;
return NO_MEMORY;
}
memset(static_cast<void *>(memPool), 0, sizeof(rml::internal::MemoryPool));
memset(static_cast<void*>(memPool), 0, sizeof(rml::internal::MemoryPool));
if (!memPool->init(pool_id, policy)) {
internalFree(memPool);
*pool = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/tbbmalloc/large_objects.h
Expand Up @@ -174,7 +174,7 @@ class LargeObjectCacheImpl {

public:
void init() {
memset(static_cast<void *>(this), 0, sizeof(CacheBin));
memset(static_cast<void*>(this), 0, sizeof(CacheBin));
}

/* ---------- Cache accessors ---------- */
Expand Down

0 comments on commit f6aee25

Please sign in to comment.