Lines Matching refs:storage

43 #define ICV_FREE_PTR(storage)  \  argument
44 ((schar*)(storage)->top + (storage)->block_size - (storage)->free_space)
83 icvInitMemStorage( CvMemStorage* storage, int block_size ) in icvInitMemStorage() argument
89 if( !storage ) in icvInitMemStorage()
98 memset( storage, 0, sizeof( *storage )); in icvInitMemStorage()
99 storage->signature = CV_STORAGE_MAGIC_VAL; in icvInitMemStorage()
100 storage->block_size = block_size; in icvInitMemStorage()
110 CvMemStorage *storage = 0; in cvCreateMemStorage() local
116 CV_CALL( storage = (CvMemStorage *)cvAlloc( sizeof( CvMemStorage ))); in cvCreateMemStorage()
117 CV_CALL( icvInitMemStorage( storage, block_size )); in cvCreateMemStorage()
122 cvFree( &storage ); in cvCreateMemStorage()
124 return storage; in cvCreateMemStorage()
132 CvMemStorage *storage = 0; in cvCreateChildMemStorage() local
140 CV_CALL( storage = cvCreateMemStorage(parent->block_size)); in cvCreateChildMemStorage()
141 storage->parent = parent; in cvCreateChildMemStorage()
146 cvFree( &storage ); in cvCreateChildMemStorage()
148 return storage; in cvCreateChildMemStorage()
154 icvDestroyMemStorage( CvMemStorage* storage ) in icvDestroyMemStorage() argument
165 if( !storage ) in icvDestroyMemStorage()
168 if( storage->parent ) in icvDestroyMemStorage()
169 dst_top = storage->parent->top; in icvDestroyMemStorage()
171 for( block = storage->bottom; block != 0; k++ ) in icvDestroyMemStorage()
176 if( storage->parent ) in icvDestroyMemStorage()
188 dst_top = storage->parent->bottom = storage->parent->top = temp; in icvDestroyMemStorage()
190 storage->free_space = storage->block_size - sizeof( *temp ); in icvDestroyMemStorage()
199 storage->top = storage->bottom = 0; in icvDestroyMemStorage()
200 storage->free_space = 0; in icvDestroyMemStorage()
208 cvReleaseMemStorage( CvMemStorage** storage ) in cvReleaseMemStorage() argument
215 if( !storage ) in cvReleaseMemStorage()
218 st = *storage; in cvReleaseMemStorage()
219 *storage = 0; in cvReleaseMemStorage()
233 cvClearMemStorage( CvMemStorage * storage ) in cvClearMemStorage() argument
239 if( !storage ) in cvClearMemStorage()
242 if( storage->parent ) in cvClearMemStorage()
244 icvDestroyMemStorage( storage ); in cvClearMemStorage()
248 storage->top = storage->bottom; in cvClearMemStorage()
249 storage->free_space = storage->bottom ? storage->block_size - sizeof(CvMemBlock) : 0; in cvClearMemStorage()
259 icvGoNextMemBlock( CvMemStorage * storage ) in icvGoNextMemBlock() argument
265 if( !storage ) in icvGoNextMemBlock()
268 if( !storage->top || !storage->top->next ) in icvGoNextMemBlock()
272 if( !(storage->parent) ) in icvGoNextMemBlock()
274 CV_CALL( block = (CvMemBlock *)cvAlloc( storage->block_size )); in icvGoNextMemBlock()
278 CvMemStorage *parent = storage->parent; in icvGoNextMemBlock()
304 block->prev = storage->top; in icvGoNextMemBlock()
306 if( storage->top ) in icvGoNextMemBlock()
307 storage->top->next = block; in icvGoNextMemBlock()
309 storage->top = storage->bottom = block; in icvGoNextMemBlock()
312 if( storage->top->next ) in icvGoNextMemBlock()
313 storage->top = storage->top->next; in icvGoNextMemBlock()
314 storage->free_space = storage->block_size - sizeof(CvMemBlock); in icvGoNextMemBlock()
315 assert( storage->free_space % CV_STRUCT_ALIGN == 0 ); in icvGoNextMemBlock()
323 cvSaveMemStoragePos( const CvMemStorage * storage, CvMemStoragePos * pos ) in cvSaveMemStoragePos() argument
329 if( !storage || !pos ) in cvSaveMemStoragePos()
332 pos->top = storage->top; in cvSaveMemStoragePos()
333 pos->free_space = storage->free_space; in cvSaveMemStoragePos()
341 cvRestoreMemStoragePos( CvMemStorage * storage, CvMemStoragePos * pos ) in cvRestoreMemStoragePos() argument
347 if( !storage || !pos ) in cvRestoreMemStoragePos()
349 if( pos->free_space > storage->block_size ) in cvRestoreMemStoragePos()
370 storage->top = pos->top; in cvRestoreMemStoragePos()
371 storage->free_space = pos->free_space; in cvRestoreMemStoragePos()
373 if( !storage->top ) in cvRestoreMemStoragePos()
375 storage->top = storage->bottom; in cvRestoreMemStoragePos()
376 storage->free_space = storage->top ? storage->block_size - sizeof(CvMemBlock) : 0; in cvRestoreMemStoragePos()
385 cvMemStorageAlloc( CvMemStorage* storage, size_t size ) in cvMemStorageAlloc() argument
393 if( !storage ) in cvMemStorageAlloc()
399 assert( storage->free_space % CV_STRUCT_ALIGN == 0 ); in cvMemStorageAlloc()
401 if( (size_t)storage->free_space < size ) in cvMemStorageAlloc()
403 … size_t max_free_space = cvAlignLeft(storage->block_size - sizeof(CvMemBlock), CV_STRUCT_ALIGN); in cvMemStorageAlloc()
407 CV_CALL( icvGoNextMemBlock( storage )); in cvMemStorageAlloc()
410 ptr = ICV_FREE_PTR(storage); in cvMemStorageAlloc()
412 storage->free_space = cvAlignLeft(storage->free_space - (int)size, CV_STRUCT_ALIGN ); in cvMemStorageAlloc()
421 cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, int len ) in cvMemStorageAllocString() argument
429 CV_CALL( str.ptr = (char*)cvMemStorageAlloc( storage, str.len + 1 )); in cvMemStorageAllocString()
445 cvCreateSeq( int seq_flags, int header_size, int elem_size, CvMemStorage * storage ) in cvCreateSeq() argument
453 if( !storage ) in cvCreateSeq()
459 CV_CALL( seq = (CvSeq*)cvMemStorageAlloc( storage, header_size )); in cvCreateSeq()
475 seq->storage = storage; in cvCreateSeq()
497 if( !seq || !seq->storage ) in cvSetSeqBlockSize()
502 useful_block_size = cvAlignLeft(seq->storage->block_size - sizeof(CvMemBlock) - in cvSetSeqBlockSize()
755 CvMemStorage *storage = seq->storage; in icvGrowSeq() local
760 if( !storage ) in icvGrowSeq()
766 if( (unsigned)(ICV_FREE_PTR(storage) - seq->block_max) < CV_STRUCT_ALIGN && in icvGrowSeq()
767 storage->free_space >= seq->elem_size && !in_front_of ) in icvGrowSeq()
769 int delta = storage->free_space / elem_size; in icvGrowSeq()
773 storage->free_space = cvAlignLeft((int)(((schar*)storage->top + storage->block_size) - in icvGrowSeq()
782 if( storage->free_space < delta ) in icvGrowSeq()
787 if( storage->free_space >= small_block_size + CV_STRUCT_ALIGN ) in icvGrowSeq()
789 delta = (storage->free_space - ICV_ALIGNED_SEQ_BLOCK_SIZE)/seq->elem_size; in icvGrowSeq()
794 CV_CALL( icvGoNextMemBlock( storage )); in icvGrowSeq()
795 assert( storage->free_space >= delta ); in icvGrowSeq()
799 CV_CALL( block = (CvSeqBlock*)cvMemStorageAlloc( storage, delta )); in icvGrowSeq()
960 int elem_size, CvMemStorage * storage, CvSeqWriter * writer ) in cvStartWriteSeq() argument
968 if( !storage || !writer ) in cvStartWriteSeq()
971 CV_CALL( seq = cvCreateSeq( seq_flags, header_size, elem_size, storage )); in cvStartWriteSeq()
1034 if( writer->block && writer->seq->storage ) in cvEndWriteSeq()
1036 CvMemStorage *storage = seq->storage; in cvEndWriteSeq() local
1037 schar *storage_block_max = (schar *) storage->top + storage->block_size; in cvEndWriteSeq()
1041 if( (unsigned)((storage_block_max - storage->free_space) in cvEndWriteSeq()
1044 storage->free_space = cvAlignLeft((int)(storage_block_max - seq->ptr), CV_STRUCT_ALIGN); in cvEndWriteSeq()
1841 cvSeqSlice( const CvSeq* seq, CvSlice slice, CvMemStorage* storage, int copy_data ) in cvSeqSlice() argument
1856 if( !storage ) in cvSeqSlice()
1858 storage = seq->storage; in cvSeqSlice()
1859 if( !storage ) in cvSeqSlice()
1873 CV_CALL( subseq = cvCreateSeq( seq->flags, seq->header_size, elem_size, storage )); in cvSeqSlice()
1887 block = (CvSeqBlock*)cvMemStorageAlloc( storage, sizeof(*block) ); in cvSeqSlice()
2599 cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, CvSeq** labels, in cvSeqPartition() argument
2622 if( !storage ) in cvSeqPartition()
2623 storage = seq->storage; in cvSeqPartition()
2625 if( !storage ) in cvSeqPartition()
2630 temp_storage = cvCreateChildMemStorage( storage ); in cvSeqPartition()
2720 result = cvCreateSeq( 0, sizeof(CvSeq), sizeof(int), storage ); in cvSeqPartition()
2759 cvCreateSet( int set_flags, int header_size, int elem_size, CvMemStorage * storage ) in cvCreateSet() argument
2767 if( !storage ) in cvCreateSet()
2774 set = (CvSet*) cvCreateSeq( set_flags, header_size, elem_size, storage ); in cvCreateSet()
2878 int vtx_size, int edge_size, CvMemStorage * storage ) in cvCreateGraph() argument
2896 CV_CALL( vertices = cvCreateSet( graph_type, header_size, vtx_size, storage )); in cvCreateGraph()
2898 sizeof( CvSet ), edge_size, storage )); in cvCreateGraph()
3460 CV_ASSERT( graph->storage != 0 ); in cvCreateGraphScanner()
3470 CV_CALL( child_storage = cvCreateChildMemStorage( graph->storage )); in cvCreateGraphScanner()
3509 CV_CALL( cvReleaseMemStorage( &((*scanner)->stack->storage))); in cvReleaseGraphScanner()
3679 cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ) in cvCloneGraph() argument
3696 if( !storage ) in cvCloneGraph()
3697 storage = graph->storage; in cvCloneGraph()
3699 if( !storage ) in cvCloneGraph()
3708 vtx_size, edge_size, storage )); in cvCloneGraph()
3774 cvTreeToNodeSeq( const void* first, int header_size, CvMemStorage* storage ) in cvTreeToNodeSeq() argument
3784 if( !storage ) in cvTreeToNodeSeq()
3787 CV_CALL( allseq = cvCreateSeq( 0, header_size, sizeof(first), storage )); in cvTreeToNodeSeq()