properly named constructors and destructors
This commit is contained in:
@@ -72,9 +72,9 @@ const Instruction* Instruction_getByOpcode(Opcode opcode){
|
||||
|
||||
static HashMap(Opcode)* opcode_map = NULL;
|
||||
|
||||
static void _opcode_map_init(){
|
||||
static void _opcode_map_construct(){
|
||||
opcode_map = malloc(sizeof(*opcode_map));
|
||||
HashMap_create(opcode_map, Opcode, NULL);
|
||||
HashMap_construct(opcode_map, Opcode, NULL);
|
||||
for(u32 i = 0; i < Array_len(&instructions_array, Instruction); i++){
|
||||
Instruction* instr_ptr = (Instruction*)instructions_array.data + i;
|
||||
HashMap_tryPush(opcode_map, instr_ptr->name, &instr_ptr->opcode);
|
||||
@@ -83,7 +83,7 @@ static void _opcode_map_init(){
|
||||
|
||||
const Instruction* Instruction_getByName(str name){
|
||||
if(opcode_map == NULL)
|
||||
_opcode_map_init();
|
||||
_opcode_map_construct();
|
||||
|
||||
str name_upper = str_toUpper(name);
|
||||
Opcode* op_ptr = HashMap_tryGetPtr(opcode_map, name_upper);
|
||||
@@ -93,7 +93,7 @@ const Instruction* Instruction_getByName(str name){
|
||||
return Instruction_getByOpcode(*op_ptr);
|
||||
}
|
||||
|
||||
void Instruction_freeSearchStructs(){
|
||||
void Instruction_destroySearchStructs(){
|
||||
if(opcode_map != NULL){
|
||||
HashMap_destroy(opcode_map);
|
||||
free(opcode_map);
|
||||
|
||||
@@ -53,4 +53,4 @@ typedef struct Instruction {
|
||||
/// @return ptr to struct or NULL
|
||||
const Instruction* NULLABLE(Instruction_getByOpcode)(Opcode opcode);
|
||||
const Instruction* NULLABLE(Instruction_getByName)(str name);
|
||||
void Instruction_freeSearchStructs();
|
||||
void Instruction_destroySearchStructs();
|
||||
|
||||
Reference in New Issue
Block a user