Coverage Report

Created: 2026-08-09 07:14

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