MCPcopy Create free account
hub / github.com/creatale/node-dv / cvMemStorageAlloc

Function cvMemStorageAlloc

deps/opencv/modules/core/src/datastructs.cpp:316–342  ·  view source on GitHub ↗

Allocate continuous buffer of the specified size in the storage: */

Source from the content-addressed store, hash-verified

314
315/* Allocate continuous buffer of the specified size in the storage: */
316CV_IMPL void*
317cvMemStorageAlloc( CvMemStorage* storage, size_t size )
318{
319 schar *ptr = 0;
320 if( !storage )
321 CV_Error( CV_StsNullPtr, "NULL storage pointer" );
322
323 if( size > INT_MAX )
324 CV_Error( CV_StsOutOfRange, "Too large memory block is requested" );
325
326 assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
327
328 if( (size_t)storage->free_space < size )
329 {
330 size_t max_free_space = cvAlignLeft(storage->block_size - sizeof(CvMemBlock), CV_STRUCT_ALIGN);
331 if( max_free_space < size )
332 CV_Error( CV_StsOutOfRange, "requested size is negative or too big" );
333
334 icvGoNextMemBlock( storage );
335 }
336
337 ptr = ICV_FREE_PTR(storage);
338 assert( (size_t)ptr % CV_STRUCT_ALIGN == 0 );
339 storage->free_space = cvAlignLeft(storage->free_space - (int)size, CV_STRUCT_ALIGN );
340
341 return ptr;
342}
343
344
345CV_IMPL CvString

Callers 8

cvMemStorageAllocStringFunction · 0.85
cvCreateSeqFunction · 0.85
icvGrowSeqFunction · 0.85
cvSeqSliceFunction · 0.85
cvCreateMapFunction · 0.85
icvXMLParseTagFunction · 0.85
persistence.cppFile · 0.85
icvAllocWSNodesFunction · 0.85

Calls 2

cvAlignLeftFunction · 0.85
icvGoNextMemBlockFunction · 0.85

Tested by

no test coverage detected