| 10489 | |
| 10490 | |
| 10491 | void init_rete(agent* thisAgent) |
| 10492 | { |
| 10493 | |
| 10494 | /* |
| 10495 | This function consists of two parts. The first initializes variables |
| 10496 | pertaining to a particular agent. The second initializes some important |
| 10497 | globals (bnode type names, addition routines, and test routines). |
| 10498 | Originally, these two parts were ordered the other way. |
| 10499 | |
| 10500 | The globals should only be initialized once (when the rete for the first |
| 10501 | agent is initialized), whereas everything else should be initialized on |
| 10502 | every call to the function (i.e. whenever the rete for a new agent is |
| 10503 | initialized). |
| 10504 | |
| 10505 | Therefore, the order has been switched so that the agent-specific |
| 10506 | variables are initialized first. Once this is done, a simple test of a |
| 10507 | static boolean variable indicates whether or not the globals have already |
| 10508 | been initialized. If they have, then the function exits prematurely. |
| 10509 | |
| 10510 | As far as I can see, this switch has no undesired effects, since the |
| 10511 | agent-specific function calls in the first part do not depend upon the |
| 10512 | global variables defined in the second part. |
| 10513 | |
| 10514 | -AJC (8/9/02) |
| 10515 | */ |
| 10516 | |
| 10517 | int i; |
| 10518 | |
| 10519 | init_memory_pool(thisAgent, &thisAgent->alpha_mem_pool, sizeof(alpha_mem), |
| 10520 | "alpha mem"); |
| 10521 | init_memory_pool(thisAgent, &thisAgent->rete_test_pool, sizeof(rete_test), |
| 10522 | "rete test"); |
| 10523 | init_memory_pool(thisAgent, &thisAgent->rete_node_pool, sizeof(rete_node), |
| 10524 | "rete node"); |
| 10525 | init_memory_pool(thisAgent, &thisAgent->node_varnames_pool, sizeof(node_varnames), |
| 10526 | "node varnames"); |
| 10527 | init_memory_pool(thisAgent, &thisAgent->token_pool, sizeof(token), "token"); |
| 10528 | init_memory_pool(thisAgent, &thisAgent->right_mem_pool, sizeof(right_mem), |
| 10529 | "right mem"); |
| 10530 | init_memory_pool(thisAgent, &thisAgent->ms_change_pool, sizeof(ms_change), |
| 10531 | "ms change"); |
| 10532 | |
| 10533 | for (i = 0; i < 16; i++) |
| 10534 | { |
| 10535 | thisAgent->alpha_hash_tables[i] = make_hash_table(thisAgent, 0, hash_alpha_mem); |
| 10536 | } |
| 10537 | |
| 10538 | thisAgent->left_ht = allocate_memory_and_zerofill |
| 10539 | (thisAgent, sizeof(char*) * LEFT_HT_SIZE, HASH_TABLE_MEM_USAGE); |
| 10540 | thisAgent->right_ht = allocate_memory_and_zerofill |
| 10541 | (thisAgent, sizeof(char*) * RIGHT_HT_SIZE, HASH_TABLE_MEM_USAGE); |
| 10542 | |
| 10543 | init_dummy_top_node(thisAgent); |
| 10544 | |
| 10545 | thisAgent->max_rhs_unbound_variables = 1; |
| 10546 | thisAgent->rhs_variable_bindings = (Symbol**) |
| 10547 | allocate_memory_and_zerofill(thisAgent, sizeof(Symbol*), MISCELLANEOUS_MEM_USAGE); |
| 10548 |
no test coverage detected