static hs_output_plugin* create_output_plugin(const hs_config* cfg, hs_sandbox_config* sbc) { hs_output_plugin* p = calloc(1, sizeof(hs_output_plugin)); if (!p) return NULL; p->list_index = -1; if (pthread_mutex_init(&p->cp_lock, NULL)) { perror("cp_lock pthread_mutex_init failed"); exit(EXIT_FAILURE); } p->sb = hs_create_output_sandbox(p, cfg, sbc); if (!p->sb) { free(p); hs_log(g_module, 3, "lsb_create_custom failed: %s/%s", sbc->dir, sbc->filename); return NULL; } if (sbc->async_buffer_size > 0) { p->async_len = sbc->async_buffer_size; p->async_cp = calloc(p->async_len, sizeof(hs_checkpoint_pair)); if (!p->async_cp) { hs_free_sandbox(p->sb); free(p); hs_log(g_module, 3, "failed allocating the async buffer"); return NULL; } lsb_add_function(p->sb->lsb, &async_checkpoint_update, "async_checkpoint_update"); } return p; }
static void free_analysis_plugin(hs_analysis_plugin* p) { if (!p->sb) return; hs_free_sandbox(p->sb); free(p->sb); p->sb = NULL; p->at = NULL; }
static void free_output_plugin(hs_output_plugin* p) { hs_free_input(&p->analysis); hs_free_input(&p->input); hs_free_sandbox(p->sb); free(p->sb); p->sb = NULL; p->plugins = NULL; free(p->async_cp); p->async_cp = NULL; p->async_len = 0; pthread_mutex_destroy(&p->cp_lock); }