Validation

Functions

void tm_validate_lists ()
 Validate internal lists against bookkeeping stats.

Function Documentation

void tm_validate_lists (  ) 

Validate internal lists against bookkeeping stats.

This is expensive.

Definition at line 236 of file debug.c.

References _tm_block_validate, tm_block::begin, tm_type::blocks, tm_type::color_list, tm_data::free_blocks, tm_data::n, tm_type::n, tm_block::next_parcel, tm, tm__LAST2, tm_assert, tm_B, tm_BLACK, tm_ECRU, tm_FREE_BLOCK, tm_GREY, tm_list_color, tm_list_LOOP, tm_list_LOOP_END, tm_LIVE_BLOCK, tm_LIVE_TYPE, tm_msg_file, tm_node_color, tm_TOTAL, tm_WHITE, tm_block::type, and tm_data::types.

00237 {
00238   int j;
00239   tm_type *t;
00240   tm_block *b;
00241   tm_node *node;
00242   size_t n[tm__LAST2];
00243   size_t bn[tm__LAST2];
00244   size_t tn[tm__LAST2];
00245 
00246   memset(n, 0, sizeof(n));
00247   memset(bn, 0, sizeof(bn));
00248 
00249 #if 0
00250   fprintf(tm_msg_file, "V");
00251   fflush(tm_msg_file);
00252 #endif
00253 
00254   /* Validate free block list. */
00255   tm_assert(tm_list_color(&tm.free_blocks) == tm_FREE_BLOCK);
00256   tm_list_LOOP(&tm.free_blocks, b);
00257   {
00258     _tm_block_validate(b);
00259     tm_assert(tm_list_color(b) == tm_FREE_BLOCK);
00260     tm_assert(b->type == 0);
00261     tm_assert(b->next_parcel == b->begin);
00262   }
00263   tm_list_LOOP_END;
00264 
00265   /* Validate types. */
00266   tm_assert(tm_list_color(&tm.types) == tm_LIVE_TYPE);
00267   tm_list_LOOP(&tm.types, t);
00268   {
00269     tm_assert(tm_list_color(t) == tm_LIVE_TYPE);
00270 
00271     /* Validate type totals. */
00272     memset(tn, 0, sizeof(n));
00273 
00274     /* Validate type blocks. */
00275     bn[tm_B] = 0;
00276     tm_assert(tm_list_color(&t->blocks) == tm_LIVE_BLOCK);
00277     tm_list_LOOP(&t->blocks, b);
00278     {
00279       _tm_block_validate(b);
00280       tm_assert(tm_list_color(b) == tm_LIVE_BLOCK);
00281       tm_assert(b->type == t);
00282       ++ bn[tm_B];
00283     }
00284     tm_list_LOOP_END;
00285     tm_assert(bn[tm_B] == t->n[tm_B]);
00286 
00287     /* Validate colored node lists. */
00288     for ( j = 0; 
00289           j < sizeof(t->color_list) / sizeof(t->color_list[0]); 
00290           ++ j ) {
00291       /* Validate lists. */
00292       tm_assert(tm_list_color(&t->color_list[j]) == j);
00293       tm_list_LOOP(&t->color_list[j], node);
00294       {
00295         tm_assert(tm_node_color(node) == j);
00296         ++ tn[j];
00297       }
00298       tm_list_LOOP_END;
00299 
00300       tm_assert(t->n[j] == tn[j]);
00301       tn[tm_TOTAL] += tn[j];
00302       n[j] += tn[j];
00303       n[tm_TOTAL] += tn[j];
00304     }
00305     tm_assert(t->n[tm_TOTAL] == tn[tm_TOTAL]);
00306   }
00307   tm_list_LOOP_END;
00308 
00309   /* Validate global node color counters. */
00310   tm_assert(n[tm_WHITE] == tm.n[tm_WHITE]);
00311   tm_assert(n[tm_ECRU]  == tm.n[tm_ECRU]);
00312   tm_assert(n[tm_GREY]  == tm.n[tm_GREY]);
00313   tm_assert(n[tm_BLACK] == tm.n[tm_BLACK]);
00314   tm_assert(n[tm_TOTAL] == tm.n[tm_TOTAL]);
00315 }


Generated on Mon Jan 25 06:33:12 2010 for TM(tredmill) by  doxygen 1.6.1