fixup EmptyPreAlarmFrames

This commit is contained in:
Isaac Connor 2020-07-20 21:02:49 -04:00
parent 41dfb8ae38
commit a0be7b1fcb
1 changed files with 18 additions and 12 deletions

View File

@ -153,12 +153,14 @@ class Event {
return pre_alarm_count;
}
static void EmptyPreAlarmFrames() {
if ( pre_alarm_count > 0 ) {
for ( int i = 0; i < MAX_PRE_ALARM_FRAMES; i++ ) {
while ( pre_alarm_count > 0 ) {
int i = pre_alarm_count - 1;
delete pre_alarm_data[i].image;
pre_alarm_data[i].image = NULL;
if ( pre_alarm_data[i].alarm_frame ) {
delete pre_alarm_data[i].alarm_frame;
pre_alarm_data[i].alarm_frame = NULL;
}
memset( pre_alarm_data, 0, sizeof(pre_alarm_data) );
}
pre_alarm_count = 0;
}
@ -173,7 +175,11 @@ class Event {
}
void SavePreAlarmFrames() {
for ( int i = 0; i < pre_alarm_count; i++ ) {
AddFrame( pre_alarm_data[i].image, pre_alarm_data[i].timestamp, pre_alarm_data[i].score, pre_alarm_data[i].alarm_frame );
AddFrame(
pre_alarm_data[i].image,
pre_alarm_data[i].timestamp,
pre_alarm_data[i].score,
pre_alarm_data[i].alarm_frame);
}
EmptyPreAlarmFrames();
}