Skip to content

Commit

Permalink
Organize code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sopiro committed May 11, 2024
1 parent da0c2fc commit eb928fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/salloc/linear_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace salloc
class LinearAllocator : public Allocator
{
public:
LinearAllocator(size_t initialCapacity = 10 * 1024);
LinearAllocator(size_t initialCapacity = 16 * 1024);
~LinearAllocator();

virtual void* Allocate(size_t size) override;
Expand Down
10 changes: 5 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_EXTENSIONS NO
)

# if(MSVC)
# target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
# else()
# target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)
# endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
3 changes: 1 addition & 2 deletions src/linear_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ bool LinearAllocator::GrowMemory()

void LinearAllocator::Clear()
{
index = 0;
entryCount = 0;
entryCapacity = 0;
index = 0;
allocation = 0;
maxAllocation = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/predefined_block_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace salloc
{

PredefinedBlockAllocator::PredefinedBlockAllocator(size_t initialChunkSize, std::span<size_t> blockSizes)
: blockCount{ 0 }
: sizeMap(std::move(blockSizes))
, blockCount{ 0 }
, chunkCount{ 0 }
, chunkSize{ initialChunkSize }
, chunks{ nullptr }
, sizeMap(std::move(blockSizes))
{
freeList = (Block**)salloc::Alloc(sizeMap.sizes.size() * sizeof(Block*));
memset(freeList, 0, sizeMap.sizes.size() * sizeof(Block*));
Expand Down

0 comments on commit eb928fe

Please sign in to comment.