Class cv::utils::BufferArea#
Manages memory block shared by muliple buffers. View details
#include <opencv2/core/utils/buffer_area.private.hpp>Collaboration diagram for cv::utils::BufferArea:
Detailed Description#
Manages memory block shared by muliple buffers.
This class allows to allocate one large memory block and split it into several smaller non-overlapping buffers. In safe mode each buffer allocation will be performed independently, this mode allows dynamic memory access instrumentation using valgrind or memory sanitizer.
Safe mode can be explicitly switched ON in constructor. It will also be enabled when compiling with memory sanitizer support or in runtime with the environment variable OPENCV_BUFFER_AREA_ALWAYS_SAFE.
Example of usage:
int * buf1 = 0;
double * buf2 = 0;
cv::util::BufferArea area;
area.allocate(buf1, 200); // buf1 = new int[200];
area.allocate(buf2, 1000, 64); // buf2 = new double[1000]; - aligned by 64
area.commit();
Note
This class is considered private and should be used only in OpenCV itself. API can be changed.
Constructor & Destructor Documentation#
BufferArea()#
cv::utils::BufferArea::BufferArea(bool safe = false)
Class constructor.
Parameters
safe— Enable safe operation mode, each allocation will be performed independently.
~BufferArea()#
cv::utils::BufferArea::~BufferArea()
Class destructor.
All allocated memory well be freed. Each bound pointer will be reset to NULL.
BufferArea()#
cv::utils::BufferArea::BufferArea(const BufferArea &)
Member Function Documentation#
allocate()#
template<typename T>
void cv::utils::BufferArea::allocate(
T *& ptr,
size_t count,
ushort alignment = sizeof(T) )
Bind a pointer to local area.
BufferArea will store reference to the pointer and allocation parameters effectively owning the pointer and allocated memory. This operation has the same parameters and does the same job as the operator new, except allocation can be performed later during the BufferArea::commit call.
Note
In safe mode allocation will be performed immediatly.
Parameters
ptr— Reference to a pointer of type T. Must be NULLcount— Count of objects to be allocated, it has the same meaning as in the operatornew.alignment— Alignment of allocated memory. same meaning as in the operatornew(C++17). Must be divisible by sizeof(T). Must be power of two.
commit()#
void cv::utils::BufferArea::commit()
Allocate memory and initialize all bound pointers.
Each pointer bound to the area with the BufferArea::allocate will be initialized and will be set to point to a memory block with requested size and alignment.
Note
Does nothing in safe mode as all allocations will be performed by BufferArea::allocate
release()#
void cv::utils::BufferArea::release()
Release all memory and unbind all pointers.
All memory will be freed and all pointers will be reset to NULL and untied from the area allowing to call allocate and commit again.
zeroFill()#
void cv::utils::BufferArea::zeroFill()
Fill all buffers with zeroes.
BufferArea::commit must be called before using this method
zeroFill()#
template<typename T>
void cv::utils::BufferArea::zeroFill(T *& ptr)
Fill one of buffers with zeroes.
BufferArea::commit must be called before using this method
Parameters
ptr— pointer to memory block previously added using BufferArea::allocate
allocate_()#
void cv::utils::BufferArea::allocate_(
void ** ptr,
ushort type_size,
size_t count,
ushort alignment )
operator=()#
BufferArea & cv::utils::BufferArea::operator=(const BufferArea &)
zeroFill_()#
void cv::utils::BufferArea::zeroFill_(void ** ptr)
Member Data Documentation#
blocks#
std::vector< Block > cv::utils::BufferArea::blocks
oneBuf#
void * cv::utils::BufferArea::oneBuf
safe#
const bool cv::utils::BufferArea::safe
totalSize#
size_t cv::utils::BufferArea::totalSize
Source file#
The documentation for this class was generated from the following file:
opencv2/core/utils/buffer_area.private.hpp