DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.54k stars 224 forks source link

Confused about the constructor in the `Array` container #405

Open lokitkhemka opened 1 month ago

lokitkhemka commented 1 month ago

Hi,

I was reading through the code of reactphysics3d, when I came across the following constructor:

Array(MemoryAllocator& allocator, uint64 capacity = 0)
            : mBuffer(nullptr), mSize(0), mCapacity(0), mAllocator(allocator)

Why is mCapacity being initialized to 0 and not capacity? I tried changing to following:

Array(MemoryAllocator& allocator, uint64 capacity = 0)
            : mBuffer(nullptr), mSize(0), mCapacity(capacity), mAllocator(allocator)

I get the access violation error thrown when running the tests. I am sorry if this is not the forum for asking such minor questions, but it is bothering me a lot. When the array is constructed without any capacity, shouldn't they be technically the same?

Thank you.