79146861

Date: 2024-11-01 03:36:35
Score: 0.5
Natty:
Report link

Smart pointers aren't necessary to achieve "memory safety," i.e. avoiding new and delete, here. The commenter was suggesting defining mBufferBlocks as:

std::vectorstd::vector<char> mBufferBlocks;

Then you know how many "buffer blocks" you have by mBufferBlocks.length() and the size of the buffer block at i using mBufferBlocks[i].length(). A buffer's data is then accesses via mBufferBlocks[i].data();

Allocating, or append()ing a new buffer is then just:

mBufferBlocks.

Releasing memory is then achieved automatically in the class' dtor().

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: nam20485