TP_13 exo1: Fix a memleak on the prompt error handling case
[TD_C.git] / TP_13 / exo1 / src / main.c
index e7472189288080d542fbfb709d6a3f01a8eab848..a68e73cb2cbf5a1b87031357c576e11eb9521993 100644 (file)
@@ -17,9 +17,9 @@ int main() {
     do {
         display_choice_menu();
         errno = prompt_value("Choix?", &choice);
-        handle_prompt_error(errno);
-        if (1 > choice || 5 < choice) {
-            printf("\nFaire un choix compris entre 1 et 5\n");
+        handle_prompt_error(errno, tab);
+        if (1 > choice || 8 < choice) {
+            printf("\nFaire un choix compris entre 1 et 8\n");
             continue;
         }
         switch (choice) {
@@ -35,11 +35,20 @@ int main() {
             case 4:
                 do_count(tab, tab_size);
                 break;
+            case 5:
+                printf("\nLe nombre d'entiers pairs dans le tableau est %d\n", count_tab_criteria(tab, tab_size, is_even));
+                break;
+            case 6:
+                printf("\nLe nombre d'entiers impairs dans le tableau est %d\n", count_tab_criteria(tab, tab_size, is_odd));
+                break;
+            case 7:
+                do_resize(tab, &tab_size);
+                break;
             default:
                 /* do nothing, unused code path */
                 break;
         }
-    } while (choice != 5);
+    } while (choice != 8);
 
     free_tab(tab);
     exit(EXIT_SUCCESS);