#include "Binary.h" void CompiledSection_construct(CompiledSection* ptr, str name){ ptr->name = name; ptr->next = NULL; ptr->offset = 0; ptr->const_data_props_list = List_construct(ConstDataProps, NULL, 0, 0); ptr->named_refs = List_construct(NamedRef, NULL, 0, 0); ptr->bytes = List_alloc(u8, 64); } void CompiledSection_destroy(CompiledSection* ptr){ free(ptr->const_data_props_list.data); free(ptr->named_refs.data); free(ptr->bytes.data); } void BinaryObject_construct(BinaryObject* ptr){ ptr->comp_sec_list = List_alloc(CompiledSection, 64); HashMap_construct(&ptr->comp_sec_i_map, u32, NULL); HashMap_construct(&ptr->const_data_props_map, ConstDataProps, NULL); ptr->main_sec = NULL; ptr->total_size = 0; } void BinaryObject_destroy(BinaryObject* ptr){ for(u32 i = 0; i < List_len(&ptr->comp_sec_list, CompiledSection); i++){ CompiledSection* sec_ptr = (CompiledSection*)ptr->comp_sec_list.data + i; CompiledSection_destroy(sec_ptr); } free(ptr->comp_sec_list.data); HashMap_destroy(&ptr->comp_sec_i_map); HashMap_destroy(&ptr->const_data_props_map); }