/src/open5gs/lib/app/ogs-context.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com> |
3 | | * |
4 | | * This file is part of Open5GS. |
5 | | * |
6 | | * This program is free software: you can redistribute it and/or modify |
7 | | * it under the terms of the GNU Affero General Public License as published by |
8 | | * the Free Software Foundation, either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | | */ |
19 | | |
20 | | #include "ogs-app.h" |
21 | | |
22 | | static ogs_app_context_t self; |
23 | | |
24 | | static int initialized = 0; |
25 | | |
26 | | int ogs_app_context_init(void) |
27 | 0 | { |
28 | 0 | ogs_assert(initialized == 0); |
29 | | |
30 | 0 | memset(&self, 0, sizeof(ogs_app_context_t)); |
31 | |
|
32 | 0 | initialized = 1; |
33 | |
|
34 | 0 | return OGS_OK; |
35 | 0 | } |
36 | | |
37 | | void ogs_app_context_final(void) |
38 | 0 | { |
39 | 0 | ogs_assert(initialized == 1); |
40 | | |
41 | 0 | if (self.document) { |
42 | 0 | yaml_document_delete(self.document); |
43 | 0 | free(self.document); |
44 | 0 | } |
45 | |
|
46 | 0 | if (self.pollset) |
47 | 0 | ogs_pollset_destroy(self.pollset); |
48 | 0 | if (self.timer_mgr) |
49 | 0 | ogs_timer_mgr_destroy(self.timer_mgr); |
50 | 0 | if (self.queue) |
51 | 0 | ogs_queue_destroy(self.queue); |
52 | |
|
53 | 0 | initialized = 0; |
54 | 0 | } |
55 | | |
56 | | ogs_app_context_t *ogs_app(void) |
57 | 0 | { |
58 | 0 | return &self; |
59 | 0 | } |