#include "win32.h" #include "libac.h" #include "config.h" #include "helpers.h" #include _Thread_local struct libac_config *config = NULL; int ac_init(const libac_config_t *c) { if (config) { return AC_E_ALREADY_INITIALIZED; } int r; if ((r = SALLOC(libac_config_t, &config))) { return r; } if (c->tok) { config->tok = c->tok; } else { if (!(config->tok = json_tokener_new())) { r = AC_E_MEMORY_ALLOCATION; goto fail; } } if (c->out) { config->out = c->out; } return AC_E_OK; fail: ac_free(); return r; } int ac_free(void) { AC_CHECK_INIT; if (config->tok) { json_tokener_free(config->tok); config->tok = NULL; } free(config); config = NULL; helpers_cleanup(); return AC_E_OK; }