Calls icvFlushSeqWriter and finishes writing process: */
| 869 | |
| 870 | /* Calls icvFlushSeqWriter and finishes writing process: */ |
| 871 | CV_IMPL CvSeq * |
| 872 | cvEndWriteSeq( CvSeqWriter * writer ) |
| 873 | { |
| 874 | if( !writer ) |
| 875 | CV_Error( CV_StsNullPtr, "" ); |
| 876 | |
| 877 | cvFlushSeqWriter( writer ); |
| 878 | CvSeq* seq = writer->seq; |
| 879 | |
| 880 | /* Truncate the last block: */ |
| 881 | if( writer->block && writer->seq->storage ) |
| 882 | { |
| 883 | CvMemStorage *storage = seq->storage; |
| 884 | schar *storage_block_max = (schar *) storage->top + storage->block_size; |
| 885 | |
| 886 | assert( writer->block->count > 0 ); |
| 887 | |
| 888 | if( (unsigned)((storage_block_max - storage->free_space) |
| 889 | - seq->block_max) < CV_STRUCT_ALIGN ) |
| 890 | { |
| 891 | storage->free_space = cvAlignLeft((int)(storage_block_max - seq->ptr), CV_STRUCT_ALIGN); |
| 892 | seq->block_max = seq->ptr; |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | writer->ptr = 0; |
| 897 | return seq; |
| 898 | } |
| 899 | |
| 900 | |
| 901 | /* Create new sequence block: */ |
no test coverage detected