/src/boringssl/crypto/stack/stack.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
2 | | * All rights reserved. |
3 | | * |
4 | | * This package is an SSL implementation written |
5 | | * by Eric Young (eay@cryptsoft.com). |
6 | | * The implementation was written so as to conform with Netscapes SSL. |
7 | | * |
8 | | * This library is free for commercial and non-commercial use as long as |
9 | | * the following conditions are aheared to. The following conditions |
10 | | * apply to all code found in this distribution, be it the RC4, RSA, |
11 | | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
12 | | * included with this distribution is covered by the same copyright terms |
13 | | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
14 | | * |
15 | | * Copyright remains Eric Young's, and as such any Copyright notices in |
16 | | * the code are not to be removed. |
17 | | * If this package is used in a product, Eric Young should be given attribution |
18 | | * as the author of the parts of the library used. |
19 | | * This can be in the form of a textual message at program startup or |
20 | | * in documentation (online or textual) provided with the package. |
21 | | * |
22 | | * Redistribution and use in source and binary forms, with or without |
23 | | * modification, are permitted provided that the following conditions |
24 | | * are met: |
25 | | * 1. Redistributions of source code must retain the copyright |
26 | | * notice, this list of conditions and the following disclaimer. |
27 | | * 2. Redistributions in binary form must reproduce the above copyright |
28 | | * notice, this list of conditions and the following disclaimer in the |
29 | | * documentation and/or other materials provided with the distribution. |
30 | | * 3. All advertising materials mentioning features or use of this software |
31 | | * must display the following acknowledgement: |
32 | | * "This product includes cryptographic software written by |
33 | | * Eric Young (eay@cryptsoft.com)" |
34 | | * The word 'cryptographic' can be left out if the rouines from the library |
35 | | * being used are not cryptographic related :-). |
36 | | * 4. If you include any Windows specific code (or a derivative thereof) from |
37 | | * the apps directory (application code) you must include an acknowledgement: |
38 | | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
39 | | * |
40 | | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
41 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
42 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
43 | | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
44 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
45 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
46 | | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
47 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
48 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
49 | | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
50 | | * SUCH DAMAGE. |
51 | | * |
52 | | * The licence and distribution terms for any publically available version or |
53 | | * derivative of this code cannot be changed. i.e. this code cannot simply be |
54 | | * copied and put under another distribution licence |
55 | | * [including the GNU Public Licence.] */ |
56 | | |
57 | | #include <openssl/stack.h> |
58 | | |
59 | | #include <assert.h> |
60 | | #include <limits.h> |
61 | | |
62 | | #include <openssl/err.h> |
63 | | #include <openssl/mem.h> |
64 | | |
65 | | #include "../internal.h" |
66 | | |
67 | | |
68 | | struct stack_st { |
69 | | // num contains the number of valid pointers in |data|. |
70 | | size_t num; |
71 | | void **data; |
72 | | // sorted is non-zero if the values pointed to by |data| are in ascending |
73 | | // order, based on |comp|. |
74 | | int sorted; |
75 | | // num_alloc contains the number of pointers allocated in the buffer pointed |
76 | | // to by |data|, which may be larger than |num|. |
77 | | size_t num_alloc; |
78 | | // comp is an optional comparison function. |
79 | | OPENSSL_sk_cmp_func comp; |
80 | | }; |
81 | | |
82 | | // kMinSize is the number of pointers that will be initially allocated in a new |
83 | | // stack. |
84 | | static const size_t kMinSize = 4; |
85 | | |
86 | 1.39k | OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_cmp_func comp) { |
87 | 1.39k | OPENSSL_STACK *ret = OPENSSL_zalloc(sizeof(OPENSSL_STACK)); |
88 | 1.39k | if (ret == NULL) { |
89 | 0 | return NULL; |
90 | 0 | } |
91 | | |
92 | 1.39k | ret->data = OPENSSL_calloc(kMinSize, sizeof(void *)); |
93 | 1.39k | if (ret->data == NULL) { |
94 | 0 | goto err; |
95 | 0 | } |
96 | | |
97 | 1.39k | ret->comp = comp; |
98 | 1.39k | ret->num_alloc = kMinSize; |
99 | | |
100 | 1.39k | return ret; |
101 | | |
102 | 0 | err: |
103 | 0 | OPENSSL_free(ret); |
104 | 0 | return NULL; |
105 | 1.39k | } |
106 | | |
107 | 2.42k | OPENSSL_STACK *OPENSSL_sk_new_null(void) { return OPENSSL_sk_new(NULL); } |
108 | | |
109 | 6.96M | size_t OPENSSL_sk_num(const OPENSSL_STACK *sk) { |
110 | 6.96M | if (sk == NULL) { |
111 | 0 | return 0; |
112 | 0 | } |
113 | 6.96M | return sk->num; |
114 | 6.96M | } |
115 | | |
116 | 0 | void OPENSSL_sk_zero(OPENSSL_STACK *sk) { |
117 | 0 | if (sk == NULL || sk->num == 0) { |
118 | 0 | return; |
119 | 0 | } |
120 | 0 | OPENSSL_memset(sk->data, 0, sizeof(void*) * sk->num); |
121 | 0 | sk->num = 0; |
122 | 0 | sk->sorted = 0; |
123 | 0 | } |
124 | | |
125 | 6.96M | void *OPENSSL_sk_value(const OPENSSL_STACK *sk, size_t i) { |
126 | 6.96M | if (!sk || i >= sk->num) { |
127 | 0 | return NULL; |
128 | 0 | } |
129 | 6.96M | return sk->data[i]; |
130 | 6.96M | } |
131 | | |
132 | 0 | void *OPENSSL_sk_set(OPENSSL_STACK *sk, size_t i, void *value) { |
133 | 0 | if (!sk || i >= sk->num) { |
134 | 0 | return NULL; |
135 | 0 | } |
136 | 0 | return sk->data[i] = value; |
137 | 0 | } |
138 | | |
139 | 18.0k | void OPENSSL_sk_free(OPENSSL_STACK *sk) { |
140 | 18.0k | if (sk == NULL) { |
141 | 8.47k | return; |
142 | 8.47k | } |
143 | 9.53k | OPENSSL_free(sk->data); |
144 | 9.53k | OPENSSL_free(sk); |
145 | 9.53k | } |
146 | | |
147 | | void OPENSSL_sk_pop_free_ex(OPENSSL_STACK *sk, |
148 | | OPENSSL_sk_call_free_func call_free_func, |
149 | 3.12k | OPENSSL_sk_free_func free_func) { |
150 | 3.12k | if (sk == NULL) { |
151 | 1.73k | return; |
152 | 1.73k | } |
153 | | |
154 | 13.5k | for (size_t i = 0; i < sk->num; i++) { |
155 | 12.1k | if (sk->data[i] != NULL) { |
156 | 12.1k | call_free_func(free_func, sk->data[i]); |
157 | 12.1k | } |
158 | 12.1k | } |
159 | 1.39k | OPENSSL_sk_free(sk); |
160 | 1.39k | } |
161 | | |
162 | | // Historically, |sk_pop_free| called the function as |OPENSSL_sk_free_func| |
163 | | // directly. This is undefined in C. Some callers called |sk_pop_free| directly, |
164 | | // so we must maintain a compatibility version for now. |
165 | 0 | static void call_free_func_legacy(OPENSSL_sk_free_func func, void *ptr) { |
166 | 0 | func(ptr); |
167 | 0 | } |
168 | | |
169 | 0 | void sk_pop_free(OPENSSL_STACK *sk, OPENSSL_sk_free_func free_func) { |
170 | 0 | OPENSSL_sk_pop_free_ex(sk, call_free_func_legacy, free_func); |
171 | 0 | } |
172 | | |
173 | 12.1k | size_t OPENSSL_sk_insert(OPENSSL_STACK *sk, void *p, size_t where) { |
174 | 12.1k | if (sk == NULL) { |
175 | 0 | return 0; |
176 | 0 | } |
177 | | |
178 | 12.1k | if (sk->num >= INT_MAX) { |
179 | 0 | OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); |
180 | 0 | return 0; |
181 | 0 | } |
182 | | |
183 | 12.1k | if (sk->num_alloc <= sk->num + 1) { |
184 | | // Attempt to double the size of the array. |
185 | 1.83k | size_t new_alloc = sk->num_alloc << 1; |
186 | 1.83k | size_t alloc_size = new_alloc * sizeof(void *); |
187 | 1.83k | void **data; |
188 | | |
189 | | // If the doubling overflowed, try to increment. |
190 | 1.83k | if (new_alloc < sk->num_alloc || alloc_size / sizeof(void *) != new_alloc) { |
191 | 0 | new_alloc = sk->num_alloc + 1; |
192 | 0 | alloc_size = new_alloc * sizeof(void *); |
193 | 0 | } |
194 | | |
195 | | // If the increment also overflowed, fail. |
196 | 1.83k | if (new_alloc < sk->num_alloc || alloc_size / sizeof(void *) != new_alloc) { |
197 | 0 | return 0; |
198 | 0 | } |
199 | | |
200 | 1.83k | data = OPENSSL_realloc(sk->data, alloc_size); |
201 | 1.83k | if (data == NULL) { |
202 | 0 | return 0; |
203 | 0 | } |
204 | | |
205 | 1.83k | sk->data = data; |
206 | 1.83k | sk->num_alloc = new_alloc; |
207 | 1.83k | } |
208 | | |
209 | 12.1k | if (where >= sk->num) { |
210 | 12.1k | sk->data[sk->num] = p; |
211 | 12.1k | } else { |
212 | 0 | OPENSSL_memmove(&sk->data[where + 1], &sk->data[where], |
213 | 0 | sizeof(void *) * (sk->num - where)); |
214 | 0 | sk->data[where] = p; |
215 | 0 | } |
216 | | |
217 | 12.1k | sk->num++; |
218 | 12.1k | sk->sorted = 0; |
219 | | |
220 | 12.1k | return sk->num; |
221 | 12.1k | } |
222 | | |
223 | | void *OPENSSL_sk_delete(OPENSSL_STACK *sk, size_t where) { |
224 | | void *ret; |
225 | | |
226 | | if (!sk || where >= sk->num) { |
227 | | return NULL; |
228 | | } |
229 | | |
230 | | ret = sk->data[where]; |
231 | | |
232 | | if (where != sk->num - 1) { |
233 | | OPENSSL_memmove(&sk->data[where], &sk->data[where + 1], |
234 | | sizeof(void *) * (sk->num - where - 1)); |
235 | | } |
236 | | |
237 | | sk->num--; |
238 | | return ret; |
239 | | } |
240 | | |
241 | 0 | void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *sk, const void *p) { |
242 | 0 | if (sk == NULL) { |
243 | 0 | return NULL; |
244 | 0 | } |
245 | | |
246 | 0 | for (size_t i = 0; i < sk->num; i++) { |
247 | 0 | if (sk->data[i] == p) { |
248 | 0 | return OPENSSL_sk_delete(sk, i); |
249 | 0 | } |
250 | 0 | } |
251 | | |
252 | 0 | return NULL; |
253 | 0 | } |
254 | | |
255 | | void OPENSSL_sk_delete_if(OPENSSL_STACK *sk, |
256 | | OPENSSL_sk_call_delete_if_func call_func, |
257 | 0 | OPENSSL_sk_delete_if_func func, void *data) { |
258 | 0 | if (sk == NULL) { |
259 | 0 | return; |
260 | 0 | } |
261 | | |
262 | 0 | size_t new_num = 0; |
263 | 0 | for (size_t i = 0; i < sk->num; i++) { |
264 | 0 | if (!call_func(func, sk->data[i], data)) { |
265 | 0 | sk->data[new_num] = sk->data[i]; |
266 | 0 | new_num++; |
267 | 0 | } |
268 | 0 | } |
269 | 0 | sk->num = new_num; |
270 | 0 | } |
271 | | |
272 | | int OPENSSL_sk_find(const OPENSSL_STACK *sk, size_t *out_index, const void *p, |
273 | 0 | OPENSSL_sk_call_cmp_func call_cmp_func) { |
274 | 0 | if (sk == NULL) { |
275 | 0 | return 0; |
276 | 0 | } |
277 | | |
278 | 0 | if (sk->comp == NULL) { |
279 | | // Use pointer equality when no comparison function has been set. |
280 | 0 | for (size_t i = 0; i < sk->num; i++) { |
281 | 0 | if (sk->data[i] == p) { |
282 | 0 | if (out_index) { |
283 | 0 | *out_index = i; |
284 | 0 | } |
285 | 0 | return 1; |
286 | 0 | } |
287 | 0 | } |
288 | 0 | return 0; |
289 | 0 | } |
290 | | |
291 | 0 | if (p == NULL) { |
292 | 0 | return 0; |
293 | 0 | } |
294 | | |
295 | 0 | if (!OPENSSL_sk_is_sorted(sk)) { |
296 | 0 | for (size_t i = 0; i < sk->num; i++) { |
297 | 0 | if (call_cmp_func(sk->comp, p, sk->data[i]) == 0) { |
298 | 0 | if (out_index) { |
299 | 0 | *out_index = i; |
300 | 0 | } |
301 | 0 | return 1; |
302 | 0 | } |
303 | 0 | } |
304 | 0 | return 0; |
305 | 0 | } |
306 | | |
307 | | // The stack is sorted, so binary search to find the element. |
308 | | // |
309 | | // |lo| and |hi| maintain a half-open interval of where the answer may be. All |
310 | | // indices such that |lo <= idx < hi| are candidates. |
311 | 0 | size_t lo = 0, hi = sk->num; |
312 | 0 | while (lo < hi) { |
313 | | // Bias |mid| towards |lo|. See the |r == 0| case below. |
314 | 0 | size_t mid = lo + (hi - lo - 1) / 2; |
315 | 0 | assert(lo <= mid && mid < hi); |
316 | 0 | int r = call_cmp_func(sk->comp, p, sk->data[mid]); |
317 | 0 | if (r > 0) { |
318 | 0 | lo = mid + 1; // |mid| is too low. |
319 | 0 | } else if (r < 0) { |
320 | 0 | hi = mid; // |mid| is too high. |
321 | 0 | } else { |
322 | | // |mid| matches. However, this function returns the earliest match, so we |
323 | | // can only return if the range has size one. |
324 | 0 | if (hi - lo == 1) { |
325 | 0 | if (out_index != NULL) { |
326 | 0 | *out_index = mid; |
327 | 0 | } |
328 | 0 | return 1; |
329 | 0 | } |
330 | | // The sample is biased towards |lo|. |mid| can only be |hi - 1| if |
331 | | // |hi - lo| was one, so this makes forward progress. |
332 | 0 | assert(mid + 1 < hi); |
333 | 0 | hi = mid + 1; |
334 | 0 | } |
335 | 0 | } |
336 | | |
337 | 0 | assert(lo == hi); |
338 | 0 | return 0; // Not found. |
339 | 0 | } |
340 | | |
341 | 0 | void *OPENSSL_sk_shift(OPENSSL_STACK *sk) { |
342 | 0 | if (sk == NULL) { |
343 | 0 | return NULL; |
344 | 0 | } |
345 | 0 | if (sk->num == 0) { |
346 | 0 | return NULL; |
347 | 0 | } |
348 | 0 | return OPENSSL_sk_delete(sk, 0); |
349 | 0 | } |
350 | | |
351 | 12.1k | size_t OPENSSL_sk_push(OPENSSL_STACK *sk, void *p) { |
352 | 12.1k | return OPENSSL_sk_insert(sk, p, sk->num); |
353 | 12.1k | } |
354 | | |
355 | 0 | void *OPENSSL_sk_pop(OPENSSL_STACK *sk) { |
356 | 0 | if (sk == NULL) { |
357 | 0 | return NULL; |
358 | 0 | } |
359 | 0 | if (sk->num == 0) { |
360 | 0 | return NULL; |
361 | 0 | } |
362 | 0 | return OPENSSL_sk_delete(sk, sk->num - 1); |
363 | 0 | } |
364 | | |
365 | 0 | OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *sk) { |
366 | 0 | if (sk == NULL) { |
367 | 0 | return NULL; |
368 | 0 | } |
369 | | |
370 | 0 | OPENSSL_STACK *ret = OPENSSL_zalloc(sizeof(OPENSSL_STACK)); |
371 | 0 | if (ret == NULL) { |
372 | 0 | return NULL; |
373 | 0 | } |
374 | | |
375 | 0 | ret->data = OPENSSL_memdup(sk->data, sizeof(void *) * sk->num_alloc); |
376 | 0 | if (ret->data == NULL) { |
377 | 0 | goto err; |
378 | 0 | } |
379 | | |
380 | 0 | ret->num = sk->num; |
381 | 0 | ret->sorted = sk->sorted; |
382 | 0 | ret->num_alloc = sk->num_alloc; |
383 | 0 | ret->comp = sk->comp; |
384 | 0 | return ret; |
385 | | |
386 | 0 | err: |
387 | 0 | OPENSSL_sk_free(ret); |
388 | 0 | return NULL; |
389 | 0 | } |
390 | | |
391 | 0 | static size_t parent_idx(size_t idx) { |
392 | 0 | assert(idx > 0); |
393 | 0 | return (idx - 1) / 2; |
394 | 0 | } |
395 | | |
396 | 0 | static size_t left_idx(size_t idx) { |
397 | | // The largest possible index is |PTRDIFF_MAX|, not |SIZE_MAX|. If |
398 | | // |ptrdiff_t|, a signed type, is the same size as |size_t|, this cannot |
399 | | // overflow. |
400 | 0 | assert(idx <= PTRDIFF_MAX); |
401 | 0 | static_assert(PTRDIFF_MAX <= (SIZE_MAX - 1) / 2, "2 * idx + 1 may oveflow"); |
402 | 0 | return 2 * idx + 1; |
403 | 0 | } |
404 | | |
405 | | // down_heap fixes the subtree rooted at |i|. |i|'s children must each satisfy |
406 | | // the heap property. Only the first |num| elements of |sk| are considered. |
407 | | static void down_heap(OPENSSL_STACK *sk, OPENSSL_sk_call_cmp_func call_cmp_func, |
408 | 0 | size_t i, size_t num) { |
409 | 0 | assert(i < num && num <= sk->num); |
410 | 0 | for (;;) { |
411 | 0 | size_t left = left_idx(i); |
412 | 0 | if (left >= num) { |
413 | 0 | break; // No left child. |
414 | 0 | } |
415 | | |
416 | | // Swap |i| with the largest of its children. |
417 | 0 | size_t next = i; |
418 | 0 | if (call_cmp_func(sk->comp, sk->data[next], sk->data[left]) < 0) { |
419 | 0 | next = left; |
420 | 0 | } |
421 | 0 | size_t right = left + 1; // Cannot overflow because |left < num|. |
422 | 0 | if (right < num && |
423 | 0 | call_cmp_func(sk->comp, sk->data[next], sk->data[right]) < 0) { |
424 | 0 | next = right; |
425 | 0 | } |
426 | |
|
427 | 0 | if (i == next) { |
428 | 0 | break; // |i| is already larger than its children. |
429 | 0 | } |
430 | | |
431 | 0 | void *tmp = sk->data[i]; |
432 | 0 | sk->data[i] = sk->data[next]; |
433 | 0 | sk->data[next] = tmp; |
434 | 0 | i = next; |
435 | 0 | } |
436 | 0 | } |
437 | | |
438 | | void OPENSSL_sk_sort(OPENSSL_STACK *sk, |
439 | 0 | OPENSSL_sk_call_cmp_func call_cmp_func) { |
440 | 0 | if (sk == NULL || sk->comp == NULL || sk->sorted) { |
441 | 0 | return; |
442 | 0 | } |
443 | | |
444 | 0 | if (sk->num >= 2) { |
445 | | // |qsort| lacks a context parameter in the comparison function for us to |
446 | | // pass in |call_cmp_func| and |sk->comp|. While we could cast |sk->comp| to |
447 | | // the expected type, it is undefined behavior in C can trip sanitizers. |
448 | | // |qsort_r| and |qsort_s| avoid this, but using them is impractical. See |
449 | | // https://stackoverflow.com/a/39561369 |
450 | | // |
451 | | // Use our own heap sort instead. This is not performance-sensitive, so we |
452 | | // optimize for simplicity and size. First, build a max-heap in place. |
453 | 0 | for (size_t i = parent_idx(sk->num - 1); i < sk->num; i--) { |
454 | 0 | down_heap(sk, call_cmp_func, i, sk->num); |
455 | 0 | } |
456 | | |
457 | | // Iteratively remove the maximum element to populate the result in reverse. |
458 | 0 | for (size_t i = sk->num - 1; i > 0; i--) { |
459 | 0 | void *tmp = sk->data[0]; |
460 | 0 | sk->data[0] = sk->data[i]; |
461 | 0 | sk->data[i] = tmp; |
462 | 0 | down_heap(sk, call_cmp_func, 0, i); |
463 | 0 | } |
464 | 0 | } |
465 | 0 | sk->sorted = 1; |
466 | 0 | } |
467 | | |
468 | 0 | int OPENSSL_sk_is_sorted(const OPENSSL_STACK *sk) { |
469 | 0 | if (!sk) { |
470 | 0 | return 1; |
471 | 0 | } |
472 | | // Zero- and one-element lists are always sorted. |
473 | 0 | return sk->sorted || (sk->comp != NULL && sk->num < 2); |
474 | 0 | } |
475 | | |
476 | | OPENSSL_sk_cmp_func OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, |
477 | 0 | OPENSSL_sk_cmp_func comp) { |
478 | 0 | OPENSSL_sk_cmp_func old = sk->comp; |
479 | |
|
480 | 0 | if (sk->comp != comp) { |
481 | 0 | sk->sorted = 0; |
482 | 0 | } |
483 | 0 | sk->comp = comp; |
484 | |
|
485 | 0 | return old; |
486 | 0 | } |
487 | | |
488 | | OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, |
489 | | OPENSSL_sk_call_copy_func call_copy_func, |
490 | | OPENSSL_sk_copy_func copy_func, |
491 | | OPENSSL_sk_call_free_func call_free_func, |
492 | | OPENSSL_sk_free_func free_func) { |
493 | | OPENSSL_STACK *ret = OPENSSL_sk_dup(sk); |
494 | | if (ret == NULL) { |
495 | | return NULL; |
496 | | } |
497 | | |
498 | | for (size_t i = 0; i < ret->num; i++) { |
499 | | if (ret->data[i] == NULL) { |
500 | | continue; |
501 | | } |
502 | | ret->data[i] = call_copy_func(copy_func, ret->data[i]); |
503 | | if (ret->data[i] == NULL) { |
504 | | for (size_t j = 0; j < i; j++) { |
505 | | if (ret->data[j] != NULL) { |
506 | | call_free_func(free_func, ret->data[j]); |
507 | | } |
508 | | } |
509 | | OPENSSL_sk_free(ret); |
510 | | return NULL; |
511 | | } |
512 | | } |
513 | | |
514 | | return ret; |
515 | | } |
516 | | |
517 | 0 | OPENSSL_STACK *sk_new_null(void) { return OPENSSL_sk_new_null(); } |
518 | | |
519 | 0 | size_t sk_num(const OPENSSL_STACK *sk) { return OPENSSL_sk_num(sk); } |
520 | | |
521 | 0 | void *sk_value(const OPENSSL_STACK *sk, size_t i) { |
522 | 0 | return OPENSSL_sk_value(sk, i); |
523 | 0 | } |
524 | | |
525 | 0 | void sk_free(OPENSSL_STACK *sk) { OPENSSL_sk_free(sk); } |
526 | | |
527 | 0 | size_t sk_push(OPENSSL_STACK *sk, void *p) { return OPENSSL_sk_push(sk, p); } |
528 | | |
529 | 0 | void *sk_pop(OPENSSL_STACK *sk) { return OPENSSL_sk_pop(sk); } |
530 | | |
531 | | void sk_pop_free_ex(OPENSSL_STACK *sk, OPENSSL_sk_call_free_func call_free_func, |
532 | 0 | OPENSSL_sk_free_func free_func) { |
533 | 0 | OPENSSL_sk_pop_free_ex(sk, call_free_func, free_func); |
534 | 0 | } |