Coverage Report

Created: 2026-06-20 07:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fluent-bit/lib/cprofiles/cprof_resource_profiles.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
0
struct cprof_resource_profiles *cprof_resource_profiles_create(char *schema_url) {
24
0
    struct cprof_resource_profiles *instance;
25
0
    cfl_sds_t                       schema_url_copy;
26
27
0
    instance = calloc(1, sizeof(struct cprof_resource_profiles));
28
29
0
    if (instance != NULL) {
30
0
        if (schema_url == NULL) {
31
0
            free(instance);
32
33
0
            instance = NULL;
34
0
        }
35
0
        else {
36
0
            schema_url_copy = cfl_sds_create(schema_url);
37
38
0
            if (schema_url_copy == NULL) {
39
0
                free(instance);
40
41
0
                instance = NULL;
42
0
            }
43
0
            else {
44
0
                instance->schema_url = schema_url_copy;
45
0
                cfl_list_init(&instance->scope_profiles);
46
0
            }
47
0
        }
48
0
    }
49
50
0
    return instance;
51
0
}
52
53
54
0
void cprof_resource_profiles_destroy(struct cprof_resource_profiles *instance) {
55
0
    struct cfl_list             *iterator;
56
0
    struct cprof_scope_profiles *scope_profiles;
57
0
    struct cfl_list             *iterator_backup;
58
59
0
    if (instance != NULL) {
60
0
        if (instance->schema_url != NULL) {
61
0
            cfl_sds_destroy(instance->schema_url);
62
0
        }
63
64
0
        if (instance->resource != NULL) {
65
0
            cprof_resource_destroy(instance->resource);
66
0
        }
67
68
0
        cfl_list_foreach_safe(iterator,
69
0
                              iterator_backup,
70
0
                              &instance->scope_profiles) {
71
0
            scope_profiles = cfl_list_entry(iterator,
72
0
                                            struct cprof_scope_profiles, _head);
73
74
0
            cfl_list_del(&scope_profiles->_head);
75
76
0
            cprof_scope_profiles_destroy(scope_profiles);
77
0
        }
78
79
0
        free(instance);
80
0
    }
81
0
}