Coverage Report

Created: 2025-10-28 07:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/htslib/bgzf_internal.h
Line
Count
Source
1
/*  bgzf_internal.h -- internal bgzf functions; not part of the public API.
2
3
    Copyright (C) 2025 Genome Research Ltd.
4
5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
of this software and associated documentation files (the "Software"), to deal
7
in the Software without restriction, including without limitation the rights
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the Software is
10
furnished to do so, subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
14
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
DEALINGS IN THE SOFTWARE.  */
22
23
#include <assert.h>
24
#include "htslib/bgzf.h"
25
26
/*
27
 * BGZF private data interface
28
 * This exists so that we can pass BCF headers into interfaces that have
29
 * traditionally only taken a BGZF pointer without a corresponding bcf_hdr_t *,
30
 * notably the bcf_readrec() function used by BCF iterators.
31
 *
32
 * To preserve the BGZF API and ABI, this is tagged on to the existing
33
 * opaque bgzf_cache_t structure.  bgzf_cache_t is now defined here so we can
34
 * inline lookups.
35
 */
36
37
typedef void bgzf_private_data_cleanup_func(void *private_data);
38
39
struct kh_bgzf_cache_s;
40
41
struct bgzf_cache_t {
42
    struct kh_bgzf_cache_s *h;
43
    unsigned int last_pos;
44
    void *private_data;
45
    bgzf_private_data_cleanup_func *private_data_cleanup;
46
};
47
48
// Set private data.  cleanup will be called on bgzf_close() or
49
// bgzf_clear_private_data();
50
51
static inline void bgzf_set_private_data(BGZF *fp, void *private_data,
52
1.80k
                                         bgzf_private_data_cleanup_func *fn) {
53
1.80k
    assert(fp->cache != NULL);
54
1.80k
    fp->cache->private_data = private_data;
55
1.80k
    fp->cache->private_data_cleanup = fn;
56
1.80k
}
vcf.c:bgzf_set_private_data
Line
Count
Source
52
1.80k
                                         bgzf_private_data_cleanup_func *fn) {
53
1.80k
    assert(fp->cache != NULL);
54
1.80k
    fp->cache->private_data = private_data;
55
1.80k
    fp->cache->private_data_cleanup = fn;
56
1.80k
}
Unexecuted instantiation: bgzf.c:bgzf_set_private_data
57
58
9.07k
static inline void bgzf_clear_private_data(BGZF *fp) {
59
9.07k
    assert(fp->cache != NULL);
60
9.07k
    if (fp->cache->private_data) {
61
1.80k
        if (fp->cache->private_data_cleanup)
62
1.80k
            fp->cache->private_data_cleanup(fp->cache->private_data);
63
1.80k
        fp->cache->private_data = NULL;
64
1.80k
    }
65
9.07k
}
Unexecuted instantiation: vcf.c:bgzf_clear_private_data
bgzf.c:bgzf_clear_private_data
Line
Count
Source
58
9.07k
static inline void bgzf_clear_private_data(BGZF *fp) {
59
9.07k
    assert(fp->cache != NULL);
60
9.07k
    if (fp->cache->private_data) {
61
1.80k
        if (fp->cache->private_data_cleanup)
62
1.80k
            fp->cache->private_data_cleanup(fp->cache->private_data);
63
        fp->cache->private_data = NULL;
64
1.80k
    }
65
9.07k
}
66
67
0
static inline void * bgzf_get_private_data(BGZF *fp) {
68
0
    assert(fp->cache != NULL);
69
0
    return fp->cache->private_data;
70
0
}
Unexecuted instantiation: vcf.c:bgzf_get_private_data
Unexecuted instantiation: bgzf.c:bgzf_get_private_data