blob: e2ee8729439c42d2b95d62eaf60d23b73f26a6a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "win32.h"
#include "libac.h"
#include "config.h"
#include "helpers.h"
#include <stdlib.h>
_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;
}
|