1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

lldp: rename lldp_neighbor_id_hash_ops and set value destructor

This commit is contained in:
Yu Watanabe 2018-11-26 03:38:48 +09:00
parent e924c60f69
commit 8276855e48
3 changed files with 5 additions and 7 deletions

View File

@ -34,7 +34,8 @@ int lldp_neighbor_id_compare_func(const LLDPNeighborID *x, const LLDPNeighborID
return CMP(x->port_id_size, y->port_id_size);
}
DEFINE_HASH_OPS(lldp_neighbor_id_hash_ops, LLDPNeighborID, lldp_neighbor_id_hash_func, lldp_neighbor_id_compare_func);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(lldp_neighbor_hash_ops, LLDPNeighborID, lldp_neighbor_id_hash_func, lldp_neighbor_id_compare_func,
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;

View File

@ -80,7 +80,7 @@ static inline void* LLDP_NEIGHBOR_TLV_DATA(const sd_lldp_neighbor *n) {
return ((uint8_t*) LLDP_NEIGHBOR_RAW(n)) + n->rindex + 2;
}
extern const struct hash_ops lldp_neighbor_id_hash_ops;
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);

View File

@ -27,12 +27,9 @@ static const char * const lldp_event_table[_SD_LLDP_EVENT_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(lldp_event, sd_lldp_event);
static void lldp_flush_neighbors(sd_lldp *lldp) {
sd_lldp_neighbor *n;
assert(lldp);
while ((n = hashmap_first(lldp->neighbor_by_id)))
lldp_neighbor_unlink(n);
hashmap_clear(lldp->neighbor_by_id);
}
static void lldp_callback(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n) {
@ -375,7 +372,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
.capability_mask = (uint16_t) -1,
};
lldp->neighbor_by_id = hashmap_new(&lldp_neighbor_id_hash_ops);
lldp->neighbor_by_id = hashmap_new(&lldp_neighbor_hash_ops);
if (!lldp->neighbor_by_id)
return -ENOMEM;