Author: marek Date: 2009-10-16 17:59:45 +0000 (Fri, 16 Oct 2009) New Revision: 1441
Modified: trunk/batctl/bat-hosts.c Log: [batctl] bisect - fix handling of large bat-host files
Modified: trunk/batctl/bat-hosts.c =================================================================== --- trunk/batctl/bat-hosts.c 2009-10-09 17:11:51 UTC (rev 1440) +++ trunk/batctl/bat-hosts.c 2009-10-16 17:59:45 UTC (rev 1441) @@ -59,7 +59,7 @@ return (hash % size); }
-static void parse_hosts_file(struct hashtable_t *hash, const char path[]) +static void parse_hosts_file(struct hashtable_t **hash, const char path[]) { FILE *fd; char name[HOST_NAME_MAX_LEN], mac_str[18]; @@ -97,7 +97,7 @@ if (bat_host) { printf("Warning - name already known (changing mac from '%s' to '%s'): %s\n", ether_ntoa(&bat_host->mac_addr), mac_str, name); - hash_remove(hash, bat_host); + hash_remove(*hash, bat_host); free(bat_host); }
@@ -111,15 +111,15 @@ memcpy(&bat_host->mac_addr, mac_addr, sizeof(struct ether_addr)); strncpy(bat_host->name, name, HOST_NAME_MAX_LEN - 1);
- hash_add(hash, bat_host); + hash_add(*hash, bat_host);
- if (hash->elements * 4 > hash->size) { - swaphash = hash_resize(hash, hash->size * 2); + if ((*hash)->elements * 4 > (*hash)->size) { + swaphash = hash_resize((*hash), (*hash)->size * 2);
if (swaphash == NULL) printf("Warning - couldn't resize bat hosts hash table\n"); else - hash = swaphash; + *hash = swaphash; }
} @@ -158,7 +158,7 @@ confdir[CONF_DIR_LEN - 1] = '\0'; }
- parse_hosts_file(host_hash, confdir); + parse_hosts_file(&host_hash, confdir); } }