/src/fluent-bit/lib/cprofiles/cprofiles.c
Line | Count | Source |
1 | | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* CProfiles |
4 | | * ========= |
5 | | * Copyright (C) 2024 The CProfiles Authors |
6 | | * |
7 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | | * you may not use this file except in compliance with the License. |
9 | | * You may obtain a copy of the License at |
10 | | * |
11 | | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | | * |
13 | | * Unless required by applicable law or agreed to in writing, software |
14 | | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | | * See the License for the specific language governing permissions and |
17 | | * limitations under the License. |
18 | | */ |
19 | | |
20 | | |
21 | | #include <cprofiles/cprofiles.h> |
22 | | |
23 | | struct cprof *cprof_create() |
24 | 0 | { |
25 | 0 | struct cprof *cprof; |
26 | |
|
27 | 0 | cprof = calloc(1, sizeof(struct cprof)); |
28 | 0 | if (!cprof) { |
29 | 0 | return NULL; |
30 | 0 | } |
31 | | |
32 | 0 | cfl_list_init(&cprof->profiles); |
33 | |
|
34 | 0 | return cprof; |
35 | 0 | } |
36 | | |
37 | | void cprof_destroy(struct cprof *cprof) |
38 | 0 | { |
39 | 0 | struct cprof_resource_profiles *resource_profile; |
40 | 0 | struct cfl_list *iterator_backup; |
41 | 0 | struct cfl_list *iterator; |
42 | |
|
43 | 0 | if (!cprof) { |
44 | 0 | return; |
45 | 0 | } |
46 | | |
47 | 0 | cfl_list_foreach_safe(iterator, |
48 | 0 | iterator_backup, |
49 | 0 | &cprof->profiles) { |
50 | 0 | resource_profile = cfl_list_entry(iterator, |
51 | 0 | struct cprof_resource_profiles, |
52 | 0 | _head); |
53 | |
|
54 | 0 | cfl_list_del(&resource_profile->_head); |
55 | |
|
56 | 0 | cprof_resource_profiles_destroy(resource_profile); |
57 | 0 | } |
58 | |
|
59 | 0 | free(cprof); |
60 | 0 | } |
61 | | |
62 | | char *cprof_version() |
63 | 0 | { |
64 | 0 | return CPROF_VERSION_STR; |
65 | 0 | } |