libxtables: prefix/order - fw_xalloc
It is good practice to prefix names in a library some way so that
it does not clash with external programs' variable names right
on the first try.
This change: rename fw_[cm]alloc to xtables_[cm]alloc and
move the definition from internal.h to xtables.h to avoid
potential compiler warnings.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
diff --git a/xtables.c b/xtables.c
index 6719659..564b27e 100644
--- a/xtables.c
+++ b/xtables.c
@@ -53,7 +53,10 @@
struct xtables_match *xtables_matches;
struct xtables_target *xtables_targets;
-void *fw_calloc(size_t count, size_t size)
+/**
+ * xtables_*alloc - wrappers that exit on failure
+ */
+void *xtables_calloc(size_t count, size_t size)
{
void *p;
@@ -65,7 +68,7 @@
return p;
}
-void *fw_malloc(size_t size)
+void *xtables_malloc(size_t size)
{
void *p;
@@ -379,7 +382,7 @@
break;
/* Second and subsequent clones */
- clone = fw_malloc(sizeof(struct xtables_match));
+ clone = xtables_malloc(sizeof(struct xtables_match));
memcpy(clone, ptr, sizeof(struct xtables_match));
clone->mflags = 0;
/* This is a clone: */
@@ -416,7 +419,7 @@
struct xtables_rule_match **i;
struct xtables_rule_match *newentry;
- newentry = fw_malloc(sizeof(struct xtables_rule_match));
+ newentry = xtables_malloc(sizeof(struct xtables_rule_match));
for (i = matches; *i; i = &(*i)->next) {
if (strcmp(name, (*i)->match->name) == 0)
@@ -876,7 +879,7 @@
while (host->h_addr_list[*naddr] != NULL)
++*naddr;
- addr = fw_calloc(*naddr, sizeof(struct in_addr) * *naddr);
+ addr = xtables_calloc(*naddr, sizeof(struct in_addr) * *naddr);
for (i = 0; i < *naddr; i++)
memcpy(&addr[i], host->h_addr_list[i],
sizeof(struct in_addr));
@@ -893,7 +896,7 @@
if ((addrptmp = numeric_to_ipaddr(name)) != NULL ||
(addrptmp = network_to_ipaddr(name)) != NULL) {
- addrp = fw_malloc(sizeof(struct in_addr));
+ addrp = xtables_malloc(sizeof(struct in_addr));
memcpy(addrp, addrptmp, sizeof(*addrp));
*naddrs = 1;
return addrp;
@@ -1089,7 +1092,7 @@
ip6addr_to_numeric(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr));
#endif
/* Get the first element of the address-chain */
- addr = fw_malloc(sizeof(struct in6_addr));
+ addr = xtables_malloc(sizeof(struct in6_addr));
memcpy(addr, &((const struct sockaddr_in6 *)res->ai_addr)->sin6_addr,
sizeof(struct in6_addr));
freeaddrinfo(res);
@@ -1115,7 +1118,7 @@
if ((addrptmp = numeric_to_ip6addr(name)) != NULL ||
(addrptmp = network_to_ip6addr(name)) != NULL) {
- addrp = fw_malloc(sizeof(struct in6_addr));
+ addrp = xtables_malloc(sizeof(struct in6_addr));
memcpy(addrp, addrptmp, sizeof(*addrp));
*naddrs = 1;
return addrp;