Skip to content

Commit

Permalink
avoid implicit pointer conv for c++ support
Browse files Browse the repository at this point in the history
  • Loading branch information
abxh committed Apr 15, 2024
1 parent f648651 commit e865d86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/fixed-containers/K_to_V_hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ static inline bool JOIN(K_to_V_hashtable, init_internal)(K_to_V_hashtable_type**
if (pow2_capacity > (SIZE_MAX - offsetof(K_to_V_hashtable_type, arr)) / sizeof(K_to_V_hashtable_slot_type)) {
return false;
}
*hashtable_pp = malloc(offsetof(K_to_V_hashtable_type, arr) + sizeof(K_to_V_hashtable_slot_type) * pow2_capacity);
*hashtable_pp =
(K_to_V_hashtable_type*)malloc(offsetof(K_to_V_hashtable_type, arr) + sizeof(K_to_V_hashtable_slot_type) * pow2_capacity);
if ((*hashtable_pp) == NULL) {
return false;
}
Expand Down Expand Up @@ -248,14 +249,13 @@ static inline VALUE_TYPE* JOIN(K_to_V_hashtable, get_mut)(K_to_V_hashtable_type*
}

static inline VALUE_TYPE JOIN(K_to_V_hashtable, get)(K_to_V_hashtable_type* hashtable_p, const KEY_TYPE key,
const VALUE_TYPE default_value) {
const VALUE_TYPE default_value) {
assert(hashtable_p != NULL);

VALUE_TYPE* value_p = JOIN(K_to_V_hashtable, get_mut)(hashtable_p, key);
return value_p != NULL ? *value_p : default_value;
}


static inline void JOIN(K_to_V_hashtable, set)(K_to_V_hashtable_type* hashtable_p, const KEY_TYPE key, const VALUE_TYPE value) {
assert(hashtable_p != NULL);
#define K_to_V_hashtable_is_full JOIN(K_to_V_hashtable, is_full)
Expand Down
2 changes: 1 addition & 1 deletion include/fixed-containers/T_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static inline bool JOIN(T_queue, init_internal)(T_queue_type** queue_pp, size_t
if (pow2_capacity > (SIZE_MAX - offsetof(T_queue_type, arr)) / sizeof(VALUE_TYPE)) {
return false;
}
*queue_pp = malloc(offsetof(T_queue_type, arr) + sizeof(VALUE_TYPE) * pow2_capacity);
*queue_pp = (T_queue_type*)malloc(offsetof(T_queue_type, arr) + sizeof(VALUE_TYPE) * pow2_capacity);
if ((*queue_pp) == NULL) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions include/fixed-containers/T_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <stdlib.h> // size_t, NULL, aligned_alloc, free
#include <string.h> // memcpy

#define T_stack_for_each(stack_p, index_plus_one, value) \
#define T_stack_for_each(stack_p, index_plus_one, value) \
for ((index_plus_one) = (stack_p)->count; ((index_plus_one) > 0 && ((value) = (stack_p)->arr[(index_plus_one)-1], true)); \
(index_plus_one)--)

Expand Down Expand Up @@ -74,7 +74,7 @@ static inline bool JOIN(T_stack, init)(T_stack_type** stack_pp, size_t capacity)
if (capacity == 0 || capacity > (SIZE_MAX - offsetof(T_stack_type, arr)) / sizeof(VALUE_TYPE)) {
return false;
}
*stack_pp = malloc(offsetof(T_stack_type, arr) + sizeof(VALUE_TYPE) * capacity);
*stack_pp = (T_stack_type*)malloc(offsetof(T_stack_type, arr) + sizeof(VALUE_TYPE) * capacity);
if ((*stack_pp) == NULL) {
return false;
}
Expand Down

0 comments on commit e865d86

Please sign in to comment.