|
25 | 25 | #include "globalcontext.h"
|
26 | 26 |
|
27 | 27 | #include "atom_table.h"
|
28 |
| -#include "atomshashtable.h" |
29 | 28 | #include "avmpack.h"
|
30 | 29 | #include "context.h"
|
31 | 30 | #include "defaultatoms.h"
|
@@ -98,7 +97,7 @@ GlobalContext *globalcontext_new()
|
98 | 97 |
|
99 | 98 | glb->modules_by_index = NULL;
|
100 | 99 | glb->loaded_modules_count = 0;
|
101 |
| - glb->modules_table = atomshashtable_new(); |
| 100 | + glb->modules_table = valueshashtable_new(); |
102 | 101 | if (IS_NULL_PTR(glb->modules_table)) {
|
103 | 102 | atom_table_destroy(glb->atom_table);
|
104 | 103 | free(glb);
|
@@ -637,9 +636,9 @@ term globalcontext_existing_term_from_atom_string(GlobalContext *glb, AtomString
|
637 | 636 |
|
638 | 637 | int globalcontext_insert_module(GlobalContext *global, Module *module)
|
639 | 638 | {
|
| 639 | + term module_name = module_get_name(module); |
640 | 640 | SMP_RWLOCK_WRLOCK(global->modules_lock);
|
641 |
| - AtomString module_name_atom = module_get_atom_string_by_id(module, 1, global); |
642 |
| - if (!atomshashtable_insert(global->modules_table, module_name_atom, TO_ATOMSHASHTABLE_VALUE(module))) { |
| 641 | + if (!valueshashtable_insert(global->modules_table, term_to_atom_index(module_name), TO_VALUESHASHTABLE_VALUE(module))) { |
643 | 642 | SMP_RWLOCK_UNLOCK(global->modules_lock);
|
644 | 643 | return -1;
|
645 | 644 | }
|
@@ -695,18 +694,15 @@ Module *globalcontext_load_module_from_avm(GlobalContext *global, const char *mo
|
695 | 694 | return new_module;
|
696 | 695 | }
|
697 | 696 |
|
698 |
| -Module *globalcontext_get_module(GlobalContext *global, AtomString module_name_atom) |
| 697 | +Module *globalcontext_get_module(GlobalContext *global, atom_index_t module_name_atom) |
699 | 698 | {
|
700 |
| - Module *found_module = (Module *) atomshashtable_get_value(global->modules_table, module_name_atom, (unsigned long) NULL); |
| 699 | + Module *found_module = (Module *) valueshashtable_get_value(global->modules_table, module_name_atom, TO_VALUESHASHTABLE_VALUE(NULL)); |
701 | 700 |
|
702 | 701 | if (!found_module) {
|
703 |
| - char *module_name = malloc(256 + 5); |
| 702 | + char *module_name = atom_table_atom_to_new_cstring(global->atom_table, module_name_atom, ".beam"); |
704 | 703 | if (IS_NULL_PTR(module_name)) {
|
705 | 704 | return NULL;
|
706 | 705 | }
|
707 |
| - |
708 |
| - atom_string_to_c(module_name_atom, module_name, 256); |
709 |
| - strcat(module_name, ".beam"); |
710 | 706 | Module *loaded_module = globalcontext_load_module_from_avm(global, module_name);
|
711 | 707 | if (IS_NULL_PTR(loaded_module)) {
|
712 | 708 | // Platform may implement sys_load_module_from_file
|
|
0 commit comments