chiark / gitweb /
networkd: route/address - use trivial hash functions
authorTom Gundersen <teg@jklm.no>
Mon, 28 Jul 2014 10:21:51 +0000 (12:21 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 28 Jul 2014 10:21:51 +0000 (12:21 +0200)
src/network/networkd-address.c
src/network/networkd-network.c
src/network/networkd-route.c
src/network/networkd.h

index 551c1ea9bf7d405fd29b3ff0a3c509f6462e2751..539bd98b52c98f1a5b5e5a41b0e14bf90d5876b7 100644 (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);
index 7e753e15aff27f55b69ca16898825378f0163272..c99dab809b71054d27196710e41fb28d18e9dcd0 100644 (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();
 
index 00fd9528c48586dee2cef4daa9e2efa3a208fe43..f451b975a701bb9b7ed1ecb337a8c55939f078b5 100644 (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);
index bf73fe2bd5b738890f75dd574fcc5e3d2cfc037b..766297cffa6985f802b37cbf05f943d597290c13 100644 (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;