Skip to content

Commit

Permalink
Renamed flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
nolan-veed committed Nov 16, 2023
1 parent 2d5a5e1 commit 3ebac69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/internal_modules/roc_core/slab_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ namespace roc {
namespace core {

//! Memory pool flags.
enum PoolFlags {
enum SlabPoolFlags {
//! Enable guards for buffer overflow, invalid ownership, etc.
PoolFlag_EnableGuards = (1 << 0),
SlabPoolFlag_EnableGuards = (1 << 0),
};

//! Default memory pool flags.
enum { DefaultPoolFlags = (PoolFlag_EnableGuards) };
enum { DefaultSlabPoolFlags = (SlabPoolFlag_EnableGuards) };

//! Memory pool.
//!
Expand Down Expand Up @@ -72,13 +72,13 @@ class SlabPool : public IPool, public NonCopyable<> {
//! - @p object_size defines size of single object in bytes
//! - @p min_alloc_bytes defines minimum size in bytes per request to arena
//! - @p max_alloc_bytes defines maximum size in bytes per request to arena
//! - @p flags defines options to modify behaviour as indicated in PoolFlags
//! - @p flags defines options to modify behaviour as indicated in SlabPoolFlags
explicit SlabPool(const char* name,
IArena& arena,
size_t object_size = sizeof(T),
size_t min_alloc_bytes = 0,
size_t max_alloc_bytes = 0,
size_t flags = DefaultPoolFlags)
size_t flags = DefaultSlabPoolFlags)
: impl_(name,
arena,
object_size,
Expand Down
4 changes: 2 additions & 2 deletions src/internal_modules/roc_core/slab_pool_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ SlabPoolImpl::Slot* SlabPoolImpl::take_slot_from_user_(void* memory) {

if (!is_owner) {
num_guard_failures_++;
if (flags_ & PoolFlag_EnableGuards) {
if (flags_ & SlabPoolFlag_EnableGuards) {
roc_panic("pool: attempt to deallocate slot not belonging to this pool:"
" name=%s this_pool=%p slot_pool=%p",
name_, (const void*)this, (const void*)slot_hdr->owner);
Expand All @@ -166,7 +166,7 @@ SlabPoolImpl::Slot* SlabPoolImpl::take_slot_from_user_(void* memory) {

if (!canary_before_ok || !canary_after_ok) {
num_guard_failures_++;
if (flags_ & PoolFlag_EnableGuards) {
if (flags_ & SlabPoolFlag_EnableGuards) {
roc_panic("pool: detected memory violation: name=%s ok_before=%d ok_after=%d",
name_, (int)canary_before_ok, (int)canary_after_ok);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/roc_core/test_slab_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ TEST(slab_pool, guard_object) {
TEST(slab_pool, guard_object_violations) {
TestArena arena;
SlabPool<TestObject, 1> pool("test", arena, sizeof(TestObject), 0, 0,
(DefaultPoolFlags & ~PoolFlag_EnableGuards));
(DefaultSlabPoolFlags & ~SlabPoolFlag_EnableGuards));
void* pointers[2] = {};

pointers[0] = pool.allocate();
Expand Down Expand Up @@ -529,7 +529,7 @@ TEST(slab_pool, guard_object_violations) {
TEST(slab_pool, object_ownership_guard) {
TestArena arena;
SlabPool<TestObject, 1> pool0("test", arena, sizeof(TestObject), 0, 0,
(DefaultPoolFlags & ~PoolFlag_EnableGuards));
(DefaultSlabPoolFlags & ~SlabPoolFlag_EnableGuards));
SlabPool<TestObject, 1> pool1("test", arena);

void* pointers[2] = {};
Expand Down

0 comments on commit 3ebac69

Please sign in to comment.