prioq: make prioq_ensure_put() type safe
This commit is contained in:
+1
-1
@@ -169,7 +169,7 @@ int prioq_put(Prioq *q, void *data, unsigned *idx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prioq_ensure_put(Prioq **q, compare_func_t compare_func, void *data, unsigned *idx) {
|
||||
int _prioq_ensure_put(Prioq **q, compare_func_t compare_func, void *data, unsigned *idx) {
|
||||
int r;
|
||||
|
||||
r = prioq_ensure_allocated(q, compare_func);
|
||||
|
||||
+7
-1
@@ -16,7 +16,13 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Prioq*, prioq_free);
|
||||
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func);
|
||||
|
||||
int prioq_put(Prioq *q, void *data, unsigned *idx);
|
||||
int prioq_ensure_put(Prioq **q, compare_func_t compare_func, void *data, unsigned *idx);
|
||||
int _prioq_ensure_put(Prioq **q, compare_func_t compare_func, void *data, unsigned *idx);
|
||||
#define prioq_ensure_put(q, compare_func, data, idx) \
|
||||
({ \
|
||||
int (*_func_)(const typeof((data)[0])*, const typeof((data)[0])*) = compare_func; \
|
||||
_prioq_ensure_put(q, (compare_func_t) _func_, data, idx); \
|
||||
})
|
||||
|
||||
int prioq_remove(Prioq *q, void *data, unsigned *idx);
|
||||
void prioq_reshuffle(Prioq *q, void *data, unsigned *idx);
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
|
||||
sd_lldp_neighbor,
|
||||
lldp_neighbor_unlink);
|
||||
|
||||
int lldp_neighbor_prioq_compare_func(const void *a, const void *b) {
|
||||
const sd_lldp_neighbor *x = a, *y = b;
|
||||
|
||||
int lldp_neighbor_prioq_compare_func(const sd_lldp_neighbor *x, const sd_lldp_neighbor *y) {
|
||||
assert(x);
|
||||
assert(y);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ static inline void* LLDP_NEIGHBOR_TLV_DATA(const sd_lldp_neighbor *n) {
|
||||
|
||||
extern const struct hash_ops lldp_neighbor_hash_ops;
|
||||
int lldp_neighbor_id_compare_func(const LLDPNeighborID *x, const LLDPNeighborID *y);
|
||||
int lldp_neighbor_prioq_compare_func(const void *a, const void *b);
|
||||
int lldp_neighbor_prioq_compare_func(const sd_lldp_neighbor *x, const sd_lldp_neighbor *y);
|
||||
|
||||
sd_lldp_neighbor *lldp_neighbor_unlink(sd_lldp_neighbor *n);
|
||||
sd_lldp_neighbor *lldp_neighbor_new(size_t raw_size);
|
||||
|
||||
Reference in New Issue
Block a user