• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SRI-CSL / yices2 / 12367760548

17 Dec 2024 06:41AM UTC coverage: 65.285% (-0.6%) from 65.92%
12367760548

push

github

web-flow
Fixes GitHub coverage issue (#544)

* Update action.yml

* Update action.yml

81020 of 124102 relevant lines covered (65.29%)

1509382.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.42
/src/utils/index_vectors.h
1
/*
2
 * This file is part of the Yices SMT Solver.
3
 * Copyright (C) 2017 SRI International.
4
 *
5
 * Yices is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * Yices is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with Yices.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18

19
/*
20
 * VECTORS OF INTEGERS
21
 *
22
 * Unlike ivector_t defined in vectors.h these index vectors
23
 * have a hidden header.
24
 */
25

26
#ifndef __INDEX_VECTORS_H
27
#define __INDEX_VECTORS_H
28

29
#include <stddef.h>
30
#include <stdint.h>
31
#include <stdbool.h>
32
#include <stdlib.h>
33
#include <assert.h>
34

35
#include "utils/memalloc.h"
36

37

38
typedef struct index_vector_s {
39
  uint32_t capacity;
40
  uint32_t size;
41
  int32_t data[0]; // real size is 'capacity'
42
} index_vector_t;
43

44

45

46
/*
47
 * Access to the header, given a vector v
48
 */
49
static inline index_vector_t *iv_header(int32_t *v) {
37,889,076✔
50
  return (index_vector_t *) (((char *) v) - offsetof(index_vector_t, data));
37,889,076✔
51
}
52

53
static inline uint32_t iv_size(int32_t *v) {
37,051,776✔
54
  return iv_header(v)->size;
37,051,776✔
55
}
56

57
static inline uint32_t iv_capacity(int32_t *v) {
58
  return iv_header(v)->capacity;
59
}
60

61

62
/*
63
 * Default and maximal size of an index vector
64
 */
65
#define DEF_IDX_VECTOR_SIZE 10
66
#define MAX_IDX_VECTOR_SIZE (((uint32_t)(UINT32_MAX-sizeof(index_vector_t)))/4)
67

68

69
/*
70
 * Add elem k at the end of vector *v
71
 * - if *v is NULL, allocate a fresh vector of default size
72
 */
73
extern void add_index_to_vector(int32_t **v, int32_t k);
74

75

76
/*
77
 * Make v large enough for at least n elements
78
 * - if *v is NULL, a fresh vector of size = max(n, default size) is allocated
79
 * - if *v is large enough already, nothing is done
80
 * Keep the current size unchanged (set it to 0 is *v was NULL)
81
 */
82
extern void resize_index_vector(int32_t **v, uint32_t n);
83

84

85
/*
86
 * Create a vector that contains a[0 ... n-1]
87
 */
88
extern int32_t *make_index_vector(int32_t *a, uint32_t n);
89

90

91
/*
92
 * Delete vector v
93
 */
94
static inline void delete_index_vector(int32_t *v) {
151,720✔
95
  if (v != NULL) {
151,720✔
96
    safe_free(iv_header(v));
100,714✔
97
  }
98
}
151,720✔
99

100

101
/*
102
 * Length
103
 */
104
static inline uint32_t iv_len(int32_t *v) {
269,595✔
105
  return (v == NULL) ? 0 : iv_size(v);
269,595✔
106
}
107

108

109
/*
110
 * Test emptiness
111
 */
112
static inline bool iv_is_empty(int32_t *v) {
×
113
  return v == NULL || iv_size(v) == 0;
×
114
}
115

116
/*
117
 * Empty vector v
118
 */
119
static inline void reset_index_vector(int32_t *v) {
×
120
  if (v != NULL) {
×
121
    iv_header(v)->size = 0;
×
122
  }
123
}
×
124

125

126
/*
127
 * Keep only the n first elements of v
128
 * - v must be non NULL
129
 * - n must be <= size of v
130
 */
131
static inline void index_vector_shrink(int32_t *v, uint32_t n) {
16,314✔
132
  assert(v != NULL && iv_size(v) >= n);
133
  iv_header(v)->size = n;
16,314✔
134
}
16,314✔
135

136

137

138
/*
139
 * Remove the last element of v
140
 * - v must be non-null and nonempty
141
 */
142
static inline void index_vector_pop(int32_t *v) {
143
  assert(v != NULL && iv_size(v) > 0);
144
  iv_header(v)->size --;
145
}
146

147

148
/*
149
 * Get the last element of v
150
 * - v must be non-null and nonempty
151
 */
152
static inline int32_t index_vector_last(int32_t *v) {
153
  assert(v != NULL && iv_size(v) > 0);
154
  return v[iv_size(v) - 1];
155
}
156

157

158
/*
159
 * Remove v[i] from vector v
160
 * - v must be non NULL and i must satisfy 0 <= i < iv_size(v)
161
 * - this may swap elements so the order in v is not preserved
162
 */
163
extern void clear_index_elem(int32_t *v, uint32_t i);
164

165

166
/*
167
 * Remove k from vector v
168
 * - no change if v is NULL or if k is not in v
169
 * - elements left in v are kept in order
170
 * - if k occurs several times, the last occurrence is removed
171
 */
172
extern void remove_index_from_vector(int32_t *v, int32_t k);
173

174

175
/*
176
 * Check whether k is present in v
177
 */
178
extern bool index_in_vector(int32_t *v, int32_t k);
179

180

181

182
#endif /* __INDEX_VECTORS_H */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc