status_t vmi_destroy( vmi_instance_t vmi) { if (!vmi) return VMI_FAILURE; vmi->shutting_down = TRUE; if(vmi->init_mode & VMI_INIT_EVENTS){ events_destroy(vmi); } driver_destroy(vmi); if (vmi->os_interface) { os_destroy(vmi); } if (vmi->os_data) { free(vmi->os_data); } if (vmi->arch_interface) { free(vmi->arch_interface); } vmi->os_data = NULL; pid_cache_destroy(vmi); sym_cache_destroy(vmi); rva_cache_destroy(vmi); v2p_cache_destroy(vmi); #if ENABLE_SHM_SNAPSHOT == 1 v2m_cache_destroy(vmi); #endif memory_cache_destroy(vmi); if (vmi->image_type) free(vmi->image_type); free(vmi); return VMI_SUCCESS; }
//The output needs to be destroyed overlapSet *osl_intersect(overlapSetList *osl, COMPARE_FUNC f) { int i; if(!osl->l) return NULL; overlapSet *osTmp, *os = os_dup(osl->os[0]); for(i=1; i<osl->l; i++) { osTmp = os_intersect(os, osl->os[i], f); os_destroy(os); os = osTmp; if(os->l == 0) break; } return os; }
void test_capture_stream(){ output_stream_t os = os_new_capture(4096); os_printf(&os, "hello"); test(strcmp(os.buffer_ptr, "hello") == 0, "buffer contained unexpected content: %s", os.buffer_ptr); os_printf(&os, " world"); test(strcmp(os.buffer_ptr, "hello world") == 0, "buffer contained unexpected content: %s", os.buffer_ptr); os_printf(&os, " from %s", "me"); test(strcmp(os.buffer_ptr, "hello world from me") == 0, "buffer contained unexpected content: %s", os.buffer_ptr); os_destroy(&os); }
void test_os_clear(){ output_stream_t os = os_new_capture(4096); os_printf(&os, "hello"); test(strcmp(os.buffer_ptr, "hello") == 0, "buffer contained unexpected content: %s", os.buffer_ptr); os_clear(&os); test(strcmp(os.buffer_ptr, "") == 0, "buffer should be empty now but contains: %s", os.buffer_ptr); os_printf(&os, "hello again"); test(strcmp(os.buffer_ptr, "hello again") == 0, "buffer contained unexpected content: %s", os.buffer_ptr); os_destroy(&os); }
int main(){ output_stream_t os = os_new_capture(4096); //output_stream_t os = os_new(stderr); log_setup(LOG_INFO, &os); info("test info: %d", 123); test(strcmp(os.buffer_ptr, "[info in logger_test.c:13 main()]: test info: 123\n") == 0, "expected the first log message but got %s", os.buffer_ptr); warn("test warning: %d, %s", 123, "hello"); test(strcmp(os.buffer_ptr, "[info in logger_test.c:13 main()]: test info: 123\n[warn in logger_test.c:15 main()]: test warning: 123, hello\n") == 0, "expected the first two log messages but got %s", os.buffer_ptr); error("test error: %s", "world"); test(strcmp(os.buffer_ptr, "[info in logger_test.c:13 main()]: test info: 123\n[warn in logger_test.c:15 main()]: test warning: 123, hello\n[ERROR in logger_test.c:17 main()]: test error: world\n") == 0, "expected the first tree log messages but got '%s'", os.buffer_ptr); os_destroy(&os); return show_test_report(); }
void osl_reset(overlapSetList *osl) { int i; for(i=0; i<osl->l; i++) os_destroy(osl->os[i]); osl->l = 0; }