YetAnotherCoupler
3.5.2
Loading...
Searching...
No Matches
src
core
ensure_array_size.h
Go to the documentation of this file.
1
// Copyright (c) 2024 The YAC Authors
2
//
3
// SPDX-License-Identifier: BSD-3-Clause
4
5
#ifndef ENSURE_ARRAY_SIZE_H
6
#define ENSURE_ARRAY_SIZE_H
7
8
#include <stdlib.h>
9
10
void
11
yac_realloc_array
(
void
**array,
size_t
elem_size,
size_t
*curr_array_size,
12
size_t
requested_size);
13
14
#define ENSURE_ARRAY_SIZE(arrayp, curr_array_size, req_size) \
15
do { \
16
if ((size_t)(req_size) > (size_t)(curr_array_size)) \
17
{ \
18
size_t casize = (curr_array_size); \
19
\
20
yac_realloc_array((void **)&(arrayp), sizeof(*(arrayp)), &casize, \
21
(req_size)); \
22
(curr_array_size) = casize; \
23
} \
24
} \
25
while(0)
26
27
#define ENSURE_BYTE_ARRAY_SIZE(arrayp, curr_array_size, req_size) \
28
do { \
29
if ((size_t)(req_size) > (size_t)(curr_array_size)) \
30
{ \
31
size_t casize = (curr_array_size); \
32
\
33
yac_realloc_array(&(arrayp), 1, &casize, (req_size)); \
34
\
35
(curr_array_size) = casize; \
36
} \
37
} \
38
while(0)
39
40
#endif
41
yac_realloc_array
void yac_realloc_array(void **array, size_t elem_size, size_t *curr_array_size, size_t requested_size)
Definition
ensure_array_size.c:12
Generated on Wed Dec 4 2024 11:31:42 for YetAnotherCoupler by
1.11.0