Example #1
0
int main() {
   Table *table_ptr;
   int x, y, table_size = 5;
   void *value;

   /***** Starting memory checking *****/
   start_memory_check();
   /***** Starting memory checking *****/

   create_table(&table_ptr, table_size, NULL);
   x = 2;
   put(table_ptr, "Peggy", &x);
   y = 1;
   put(table_ptr, "John", &y);

   printf("Table size: %d\n", get_table_size(table_ptr));
   if (is_empty(table_ptr)) {
      printf("Empty table\n");
   } else {
      printf("Not empty\n");
   }
   get_value(table_ptr, "John", &value);
   printf("Value for John %d\n", *(int *) value);

   printf("Removing Peggy: %d\n", remove_entry(table_ptr, "Peggy"));
   printf("Displaying Table\n");
   display_table(table_ptr);

   clear_table(table_ptr);
   printf("After clearing\n");
   if (is_empty(table_ptr)) {
      printf("Empty table\n");
   } else {
      printf("Not empty\n");
   }
   printf("Displaying Table\n");
   display_table(table_ptr);

   destroy_table(table_ptr);

   /****** Gathering memory checking info *****/
   stop_memory_check();
   /****** Gathering memory checking info *****/

   return 0;
}
Example #2
0
int main() {
   int result = SUCCESS;

   /***** Starting memory checking *****/
   start_memory_check();
   /***** Starting memory checking *****/

   if(test1() == FAILURE) result = FAILURE;
   if(test2() == FAILURE) result = FAILURE;
   if(test3() == FAILURE) result = FAILURE;
   if(test4() == FAILURE) result = FAILURE;
   if(test5() == FAILURE) result = FAILURE;

   /****** Gathering memory checking info *****/
   stop_memory_check();
   /****** Gathering memory checking info *****/
   
   if(result == FAILURE) {
      exit(EXIT_FAILURE);
   }

   return EXIT_SUCCESS;
}