From: Francois Fleuret Date: Mon, 4 Feb 2013 21:49:22 +0000 (+0100) Subject: Free regexp only for non ID_INTERVAL conditions. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=d64276379807f4208b97c3fb78e30f1d5b95f447;p=mymail.git Free regexp only for non ID_INTERVAL conditions. --- diff --git a/mymail.c b/mymail.c index 24b2aa0..b0c1216 100644 --- a/mymail.c +++ b/mymail.c @@ -376,7 +376,7 @@ void search_in_db(FILE *db_file, fseek(mail_file, current_position_in_mail, SEEK_SET); if(fgets(raw_mbox_line, BUFFER_SIZE, mail_file)) { - last_mbox_line_was_empty = 1; + last_mbox_line_was_empty = 0; fprintf(output_file, "%s", raw_mbox_line); while(1) { if(!fgets(raw_mbox_line, BUFFER_SIZE, mail_file) || @@ -865,7 +865,14 @@ int main(int argc, char **argv) { search_conditions[n].negation = 0; } - if(strcmp(search_field, "today") == 0) { + if(strcmp(search_field, "6h") == 0) { + search_conditions[n].field_id = ID_INTERVAL; + search_conditions[n].interval_start = time(0) - 3600 * 6; + search_conditions[n].interval_stop = 0; + } + + else if(strcmp(search_field, "24h") == 0 || + strcmp(search_field, "today") == 0) { search_conditions[n].field_id = ID_INTERVAL; search_conditions[n].interval_start = time(0) - 3600 * 24; search_conditions[n].interval_stop = 0; @@ -980,7 +987,9 @@ int main(int argc, char **argv) { } for(n = 0; n < nb_search_conditions; n++) { - regfree(&search_conditions[n].regexp); + if(search_conditions[n].field_id != ID_INTERVAL) { + regfree(&search_conditions[n].regexp); + } free(search_condition_strings[n]); } }