Use nwrap_ed_inventarize() instead of nwrap_add_ai().
This not only removes code duplication, but also
more correctly adds more than one line for a given
IP address in a list behind this address.
The original code would only have inventarized
the first line for an IP found.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
return el;
}
-static bool nwrap_add_ai(char *const ip_addr, struct nwrap_entdata *const ed)
-{
- ENTRY e;
- ENTRY *p;
- struct nwrap_entlist *el;
-
- if (ip_addr == NULL) {
- NWRAP_LOG(NWRAP_LOG_ERROR, "ip_addr NULL - can't add");
- return false;
- }
-
- el = nwrap_entlist_init(ed);
- if (el == NULL) {
- return false;
- }
-
- e.key = ip_addr;
- e.data = el;
-
- p = hsearch(e, ENTER);
- if (p == NULL) {
- NWRAP_LOG(NWRAP_LOG_ERROR, "Hash table is full");
- return false;
- }
-
- return true;
-}
-
-
static bool nwrap_ed_inventarize_add_new(char *const h_name,
struct nwrap_entdata *const ed)
{
return false;
}
- ok = nwrap_add_ai(ip, ed);
+ ok = nwrap_ed_inventarize(ip, ed);
if (!ok) {
return false;
}