diff --git a/src/PikaVM.c b/src/PikaVM.c index 06e34e091..cb4a66f2b 100644 --- a/src/PikaVM.c +++ b/src/PikaVM.c @@ -839,7 +839,9 @@ void constPool_init(ConstPool* self) { } void constPool_deinit(ConstPool* self) { - arg_deinit(self->arg_buff); + if (NULL != self->arg_buff) { + arg_deinit(self->arg_buff); + } } void constPool_append(ConstPool* self, char* content) { @@ -933,8 +935,10 @@ void instructArray_init(InstructArray* self) { self->content_offset_now = 0; } -void instructArray_deinit(InstructArray* ins_array) { - arg_deinit(ins_array->arg_buff); +void instructArray_deinit(InstructArray* self) { + if (NULL != self->arg_buff) { + arg_deinit(self->arg_buff); + } } void instructArray_append(InstructArray* self, InstructUnit* ins_unit) { diff --git a/src/PikaVM.h b/src/PikaVM.h index 3520b97ad..e491fd3b3 100644 --- a/src/PikaVM.h +++ b/src/PikaVM.h @@ -104,7 +104,6 @@ char* constPool_getByOffset(ConstPool* self, uint16_t offset); uint16_t constPool_getLastOffset(ConstPool* self); void constPool_print(ConstPool* self); - void byteCodeFrame_init(ByteCodeFrame* bf); void byteCodeFrame_deinit(ByteCodeFrame* bf); size_t byteCodeFrame_getSize(ByteCodeFrame* bf); @@ -118,7 +117,6 @@ void instructArray_print(InstructArray* self); void byteCodeFrame_print(ByteCodeFrame* self); InstructUnit* instructArray_getByOffset(InstructArray* self, int32_t offset); - #define instructUnit_getSize(InstructUnit_p_self) ((size_t)sizeof(InstructUnit)) #define instructArray_getSize(InsturctArry_p_self) \ ((size_t)(InsturctArry_p_self)->size) @@ -132,5 +130,6 @@ VMParameters* pikaVM_runByteCodeWithState(PikaObj* self, uint16_t constPool_getOffsetByData(ConstPool* self, char* data); void instructArray_printWithConst(InstructArray* self, ConstPool* const_pool); void constPool_update(ConstPool* self); +void instructArray_update(InstructArray* self); #endif