networkd: route/address - use trivial hash functions

This commit is contained in:
Tom Gundersen 2014-07-28 12:21:51 +02:00
parent 6a0a2f860f
commit 16aa63a00b
4 changed files with 13 additions and 13 deletions

View File

@ -41,8 +41,7 @@ int address_new_static(Network *network, unsigned section, Address **ret) {
_cleanup_address_free_ Address *address = NULL;
if (section) {
uint64_t key = section;
address = hashmap_get(network->addresses_by_section, &key);
address = hashmap_get(network->addresses_by_section, UINT_TO_PTR(section));
if (address) {
*ret = address;
address = NULL;
@ -63,7 +62,8 @@ int address_new_static(Network *network, unsigned section, Address **ret) {
if (section) {
address->section = section;
hashmap_put(network->addresses_by_section, &address->section, address);
hashmap_put(network->addresses_by_section,
UINT_TO_PTR(address->section), address);
}
*ret = address;
@ -96,7 +96,7 @@ void address_free(Address *address) {
if (address->section)
hashmap_remove(address->network->addresses_by_section,
&address->section);
UINT_TO_PTR(address->section));
}
free(address);

View File

@ -66,11 +66,11 @@ static int network_load_one(Manager *manager, const char *filename) {
if (!network->stacked_netdevs)
return log_oom();
network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
network->addresses_by_section = hashmap_new(NULL, NULL);
if (!network->addresses_by_section)
return log_oom();
network->routes_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
network->routes_by_section = hashmap_new(NULL, NULL);
if (!network->routes_by_section)
return log_oom();

View File

@ -32,9 +32,8 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
_cleanup_route_free_ Route *route = NULL;
if (section) {
uint64_t key = section;
route = hashmap_get(network->routes_by_section, &key);
route = hashmap_get(network->routes_by_section,
UINT_TO_PTR(section));
if (route) {
*ret = route;
route = NULL;
@ -57,7 +56,8 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
if (section) {
route->section = section;
hashmap_put(network->routes_by_section, &route->section, route);
hashmap_put(network->routes_by_section,
UINT_TO_PTR(route->section), route);
}
*ret = route;
@ -92,7 +92,7 @@ void route_free(Route *route) {
if (route->section)
hashmap_remove(route->network->routes_by_section,
&route->section);
UINT_TO_PTR(route->section));
}
free(route);

View File

@ -110,7 +110,7 @@ struct Network {
struct Address {
Network *network;
uint64_t section;
unsigned section;
int family;
unsigned char prefixlen;
@ -128,7 +128,7 @@ struct Address {
struct Route {
Network *network;
uint64_t section;
unsigned section;
int family;
unsigned char dst_prefixlen;