Push element onto the front of the sequence: */
| 1182 | |
| 1183 | /* Push element onto the front of the sequence: */ |
| 1184 | CV_IMPL schar* |
| 1185 | cvSeqPushFront( CvSeq *seq, const void *element ) |
| 1186 | { |
| 1187 | schar* ptr = 0; |
| 1188 | int elem_size; |
| 1189 | CvSeqBlock *block; |
| 1190 | |
| 1191 | if( !seq ) |
| 1192 | CV_Error( CV_StsNullPtr, "" ); |
| 1193 | |
| 1194 | elem_size = seq->elem_size; |
| 1195 | block = seq->first; |
| 1196 | |
| 1197 | if( !block || block->start_index == 0 ) |
| 1198 | { |
| 1199 | icvGrowSeq( seq, 1 ); |
| 1200 | |
| 1201 | block = seq->first; |
| 1202 | assert( block->start_index > 0 ); |
| 1203 | } |
| 1204 | |
| 1205 | ptr = block->data -= elem_size; |
| 1206 | |
| 1207 | if( element ) |
| 1208 | memcpy( ptr, element, elem_size ); |
| 1209 | block->count++; |
| 1210 | block->start_index--; |
| 1211 | seq->total++; |
| 1212 | |
| 1213 | return ptr; |
| 1214 | } |
| 1215 | |
| 1216 | |
| 1217 | /* Shift out first element of the sequence: */ |
no test coverage detected