Coverage Report

Created: 2026-10-28 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl34/include/internal/priority_queue.h
Line
Count
Source
1
/*
2
 * Copyright 2022-2026 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#ifndef OSSL_INTERNAL_PRIORITY_QUEUE_H
11
#define OSSL_INTERNAL_PRIORITY_QUEUE_H
12
#pragma once
13
14
#include <stdlib.h>
15
#include <openssl/e_os2.h>
16
17
#define PRIORITY_QUEUE_OF(type) OSSL_PRIORITY_QUEUE_##type
18
19
#define DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, ctype)                                                                             \
20
    typedef struct ossl_priority_queue_st_##type PRIORITY_QUEUE_OF(type);                                                          \
21
    static ossl_unused ossl_inline PRIORITY_QUEUE_OF(type) *ossl_pqueue_##type##_new(int (*compare)(const ctype *, const ctype *)) \
22
8.20M
    {                                                                                                                              \
23
8.20M
        return (PRIORITY_QUEUE_OF(type) *)ossl_pqueue_new(                                                                         \
24
8.20M
            (int (*)(const void *, const void *))compare);                                                                         \
25
8.20M
    }                                                                                                                              \
26
    static ossl_unused ossl_inline void                                                                                            \
27
    ossl_pqueue_##type##_free(PRIORITY_QUEUE_OF(type) *pq)                                                                         \
28
8.20M
    {                                                                                                                              \
29
8.20M
        ossl_pqueue_free((OSSL_PQUEUE *)pq);                                                                                       \
30
8.20M
    }                                                                                                                              \
31
    static ossl_unused ossl_inline void                                                                                            \
32
    ossl_pqueue_##type##_pop_free(PRIORITY_QUEUE_OF(type) *pq,                                                                     \
33
        void (*freefunc)(ctype *))                                                                                                 \
34
0
    {                                                                                                                              \
35
0
        ossl_pqueue_pop_free((OSSL_PQUEUE *)pq, (void (*)(void *))freefunc);                                                       \
36
0
    }                                                                                                                              \
37
    static ossl_unused ossl_inline int                                                                                             \
38
    ossl_pqueue_##type##_reserve(PRIORITY_QUEUE_OF(type) *pq, size_t n)                                                            \
39
0
    {                                                                                                                              \
40
0
        return ossl_pqueue_reserve((OSSL_PQUEUE *)pq, n);                                                                          \
41
0
    }                                                                                                                              \
42
    static ossl_unused ossl_inline size_t                                                                                          \
43
    ossl_pqueue_##type##_num(const PRIORITY_QUEUE_OF(type) *pq)                                                                    \
44
7.57M
    {                                                                                                                              \
45
7.57M
        return ossl_pqueue_num((OSSL_PQUEUE *)pq);                                                                                 \
46
7.57M
    }                                                                                                                              \
47
    static ossl_unused ossl_inline int                                                                                             \
48
    ossl_pqueue_##type##_push(PRIORITY_QUEUE_OF(type) *pq,                                                                         \
49
        ctype *data, size_t *elem)                                                                                                 \
50
6.12M
    {                                                                                                                              \
51
6.12M
        return ossl_pqueue_push((OSSL_PQUEUE *)pq, (void *)data, elem);                                                            \
52
6.12M
    }                                                                                                                              \
53
    static ossl_unused ossl_inline ctype *                                                                                         \
54
    ossl_pqueue_##type##_peek(const PRIORITY_QUEUE_OF(type) *pq)                                                                   \
55
17.7M
    {                                                                                                                              \
56
17.7M
        return (type *)ossl_pqueue_peek((OSSL_PQUEUE *)pq);                                                                        \
57
17.7M
    }                                                                                                                              \
58
    static ossl_unused ossl_inline ctype *                                                                                         \
59
    ossl_pqueue_##type##_pop(PRIORITY_QUEUE_OF(type) *pq)                                                                          \
60
10.6M
    {                                                                                                                              \
61
10.6M
        return (type *)ossl_pqueue_pop((OSSL_PQUEUE *)pq);                                                                         \
62
10.6M
    }                                                                                                                              \
63
    static ossl_unused ossl_inline ctype *                                                                                         \
64
    ossl_pqueue_##type##_remove(PRIORITY_QUEUE_OF(type) *pq,                                                                       \
65
        size_t elem)                                                                                                               \
66
3.64M
    {                                                                                                                              \
67
3.64M
        return (type *)ossl_pqueue_remove((OSSL_PQUEUE *)pq, elem);                                                                \
68
3.64M
    }                                                                                                                              \
69
    struct ossl_priority_queue_st_##type
70
71
#define DEFINE_PRIORITY_QUEUE_OF(type) \
72
    DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, type)
73
74
typedef struct ossl_pqueue_st OSSL_PQUEUE;
75
76
OSSL_PQUEUE *ossl_pqueue_new(int (*compare)(const void *, const void *));
77
void ossl_pqueue_free(OSSL_PQUEUE *pq);
78
void ossl_pqueue_pop_free(OSSL_PQUEUE *pq, void (*freefunc)(void *));
79
int ossl_pqueue_reserve(OSSL_PQUEUE *pq, size_t n);
80
81
size_t ossl_pqueue_num(const OSSL_PQUEUE *pq);
82
int ossl_pqueue_push(OSSL_PQUEUE *pq, void *data, size_t *elem);
83
void *ossl_pqueue_peek(const OSSL_PQUEUE *pq);
84
void *ossl_pqueue_pop(OSSL_PQUEUE *pq);
85
void *ossl_pqueue_remove(OSSL_PQUEUE *pq, size_t elem);
86
87
#endif