MCPcopy Create free account
hub / github.com/SoarGroup/Soar / reset_id_counters

Function reset_id_counters

Core/SoarKernel/src/symtab.cpp:663–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

661}
662
663bool reset_id_counters(agent* thisAgent)
664{
665 int i;
666
667 if (thisAgent->identifier_hash_table->count != 0)
668 {
669 // As long as all of the existing identifiers are long term identifiers (lti), there's no problem
670 uint64_t ltis = 0;
671 do_for_all_items_in_hash_table(thisAgent, thisAgent->identifier_hash_table, smem_count_ltis, &ltis);
672 if (static_cast<uint64_t>(thisAgent->identifier_hash_table->count) != ltis)
673 {
674 print(thisAgent, "Internal warning: wanted to reset identifier generator numbers, but\n");
675 print(thisAgent, "there are still some identifiers allocated. (Probably a memory leak.)\n");
676 print(thisAgent, "(Leaving identifier numbers alone.)\n");
677 xml_generate_warning(thisAgent, "Internal warning: wanted to reset identifier generator numbers, but\nthere are still some identifiers allocated. (Probably a memory leak.)\n(Leaving identifier numbers alone.)");
678
679 print_internal_symbols(thisAgent);
680 /* RDF 01272003: Added this to improve the output from this error message */
681 //TODO: append this to previous XML string or generate separate output?
682 //do_for_all_items_in_hash_table( thisAgent, thisAgent->identifier_hash_table, print_identifier_ref_info, 0);
683
684 // Also dump the ids to a txt file
685 FILE* ids = fopen("leaked-ids.txt", "w") ;
686 if (ids)
687 {
688 do_for_all_items_in_hash_table(thisAgent, thisAgent->identifier_hash_table, print_identifier_ref_info, reinterpret_cast<void*>(ids));
689 fclose(ids) ;
690 }
691
692 return false;
693 }
694
695 // Getting here means that there are still identifiers but that
696 // they are all long-term and (hopefully) exist only in production memory.
697 }
698 for (i = 0; i < 26; i++)
699 {
700 thisAgent->id_counter[i] = 1;
701 }
702
703 if (thisAgent->smem_db->get_status() == soar_module::connected)
704 {
705 smem_reset_id_counters(thisAgent);
706 }
707
708 return true ;
709}
710
711bool reset_tc_num(agent* /*thisAgent*/, void* item, void*)
712{

Callers 2

reinitialize_soarFunction · 0.85
init_symbol_tablesFunction · 0.85

Calls 6

printFunction · 0.85
xml_generate_warningFunction · 0.85
print_internal_symbolsFunction · 0.85
smem_reset_id_countersFunction · 0.85
get_statusMethod · 0.80

Tested by

no test coverage detected