Skip to content

Commit 590f7c3

Browse files
committed
Change functions in array.h and array.hpp to inline.
1 parent be5ac98 commit 590f7c3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

include/binsparse/array.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ typedef struct bsp_array_t {
2020
bsp_allocator_t allocator;
2121
} bsp_array_t;
2222

23-
bsp_array_t bsp_construct_default_array_t() {
23+
inline bsp_array_t bsp_construct_default_array_t() {
2424
bsp_array_t array;
2525
array.data = NULL;
2626
array.size = 0;
2727
array.allocator = bsp_default_allocator;
2828
return array;
2929
}
3030

31-
bsp_array_t bsp_construct_array_t(size_t size, bsp_type_t type) {
31+
inline bsp_array_t bsp_construct_array_t(size_t size, bsp_type_t type) {
3232
size_t byte_size = size * bsp_type_size(type);
3333

3434
bsp_array_t array;
@@ -41,14 +41,14 @@ bsp_array_t bsp_construct_array_t(size_t size, bsp_type_t type) {
4141
return array;
4242
}
4343

44-
bsp_array_t bsp_copy_construct_array_t(bsp_array_t other) {
44+
inline bsp_array_t bsp_copy_construct_array_t(bsp_array_t other) {
4545
bsp_array_t array = bsp_construct_array_t(other.size, other.type);
4646
memcpy(array.data, other.data, other.size * bsp_type_size(other.type));
4747

4848
return array;
4949
}
5050

51-
bsp_array_t bsp_complex_array_to_fp(bsp_array_t other) {
51+
inline bsp_array_t bsp_complex_array_to_fp(bsp_array_t other) {
5252
assert(other.type == BSP_COMPLEX_FLOAT32 ||
5353
other.type == BSP_COMPLEX_FLOAT64);
5454

@@ -66,7 +66,7 @@ bsp_array_t bsp_complex_array_to_fp(bsp_array_t other) {
6666
return array;
6767
}
6868

69-
bsp_array_t bsp_fp_array_to_complex(bsp_array_t other) {
69+
inline bsp_array_t bsp_fp_array_to_complex(bsp_array_t other) {
7070
assert(other.type == BSP_FLOAT32 || other.type == BSP_FLOAT64);
7171

7272
bsp_array_t array;
@@ -83,11 +83,11 @@ bsp_array_t bsp_fp_array_to_complex(bsp_array_t other) {
8383
return array;
8484
}
8585

86-
void bsp_destroy_array_t(bsp_array_t array) {
86+
inline void bsp_destroy_array_t(bsp_array_t array) {
8787
array.allocator.free(array.data);
8888
}
8989

90-
bool bsp_array_equal(bsp_array_t x, bsp_array_t y) {
90+
inline bool bsp_array_equal(bsp_array_t x, bsp_array_t y) {
9191
if (x.size != y.size) {
9292
return false;
9393
}

include/binsparse/detail/cpp/array.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using array_ptr_variant_t =
1919
int32_t*, int64_t*, float*, double*, float _Complex*,
2020
double _Complex*>;
2121

22-
array_ptr_variant_t get_typed_ptr(bsp_array_t array) {
22+
inline array_ptr_variant_t get_typed_ptr(bsp_array_t array) {
2323
if (array.type == BSP_UINT8) {
2424
uint8_t* data = (uint8_t*) array.data;
2525
return data;
@@ -69,7 +69,7 @@ array_ptr_variant_t get_typed_ptr(bsp_array_t array) {
6969

7070
// value = array[index]
7171
template <typename T>
72-
void bsp_array_read(bsp_array_t array, size_t index, T& value) {
72+
inline void bsp_array_read(bsp_array_t array, size_t index, T& value) {
7373
auto variant_ptr = binsparse::__detail::get_typed_ptr(array);
7474

7575
std::visit(
@@ -85,7 +85,7 @@ void bsp_array_read(bsp_array_t array, size_t index, T& value) {
8585

8686
// array[index] = value
8787
template <typename U>
88-
void bsp_array_write(bsp_array_t array, size_t index, U value) {
88+
inline void bsp_array_write(bsp_array_t array, size_t index, U value) {
8989
auto variant_ptr = binsparse::__detail::get_typed_ptr(array);
9090

9191
std::visit(
@@ -100,8 +100,8 @@ void bsp_array_write(bsp_array_t array, size_t index, U value) {
100100
}
101101

102102
// array_0[index_0] = array_1[index_1]
103-
void bsp_array_awrite(bsp_array_t array_0, size_t index_0, bsp_array_t array_1,
104-
size_t index_1) {
103+
inline void bsp_array_awrite(bsp_array_t array_0, size_t index_0,
104+
bsp_array_t array_1, size_t index_1) {
105105
auto variant_ptr_0 = binsparse::__detail::get_typed_ptr(array_0);
106106
auto variant_ptr_1 = binsparse::__detail::get_typed_ptr(array_1);
107107

0 commit comments

Comments
 (0)