Replace xmalloc() followed by memset( ..., 0, ...) with xmallocz().
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/fltedit.c | 3 +--
src/ipfrag.c | 3 +--
src/othptab.c | 3 +--
src/tcptable.c | 9 +++------
4 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/fltedit.c b/src/fltedit.c
index f5746c9..90cf471 100644
--- a/src/fltedit.c
+++ b/src/fltedit.c
@@ -177,8 +177,7 @@ void update_hp_screen(struct filterent *firstvisible, WINDOW * win)
int new_hp_entry(struct filterent **ftemp)
{
- *ftemp = xmalloc(sizeof(struct filterent));
- memset(*ftemp, 0, sizeof(struct filterent));
+ *ftemp = xmallocz(sizeof(struct filterent));
return 1;
}
diff --git a/src/ipfrag.c b/src/ipfrag.c
index 5e92da4..15a06f1 100644
--- a/src/ipfrag.c
+++ b/src/ipfrag.c
@@ -26,7 +26,7 @@ static struct fragent *addnewdgram(struct iphdr *packet)
{
struct fragent *ptmp;
- ptmp = xmalloc(sizeof(struct fragent));
+ ptmp = xmallocz(sizeof(struct fragent));
if (fraglist == NULL) {
fraglist = ptmp;
ptmp->prev_entry = NULL;
@@ -35,7 +35,6 @@ static struct fragent *addnewdgram(struct iphdr *packet)
fragtail->next_entry = ptmp;
ptmp->prev_entry = fragtail;
}
- memset(ptmp, 0, sizeof(struct fragent));
ptmp->fragdesclist = xmalloc(sizeof(struct fragdescent));
ptmp->fragdesclist->min = 0;
ptmp->fragdesclist->max = 65535;
diff --git a/src/othptab.c b/src/othptab.c
index 77efe6e..08574fb 100644
--- a/src/othptab.c
+++ b/src/othptab.c
@@ -175,8 +175,7 @@ struct othptabent *add_othp_entry(struct othptable *table, struct
pkt_hdr *pkt,
struct in_addr isaddr, idaddr;
char *packet = pkt->pkt_buf;
- new_entry = xmalloc(sizeof(struct othptabent));
- memset(new_entry, 0, sizeof(struct othptabent));
+ new_entry = xmallocz(sizeof(struct othptabent));
new_entry->is_ip = is_ip;
new_entry->fragment = fragment;
diff --git a/src/tcptable.c b/src/tcptable.c
index a26607a..bcc24ff 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -141,8 +141,7 @@ static void add_tcp_hash_entry(struct tcptable *table, struct
tcptableent *entry
entry->sport, entry->daddr.s_addr,
entry->d6addr.s6_addr32, entry->dport, entry->ifname);
- ptmp = xmalloc(sizeof(struct tcp_hashentry));
- memset(ptmp, 0, sizeof(struct tcp_hashentry));
+ ptmp = xmallocz(sizeof(struct tcp_hashentry));
/*
* Add backpointer from screen node to hash node for deletion later
* (Actually point to its predecessor coz of the header cell).
@@ -518,13 +517,11 @@ struct tcptableent *in_table(struct tcptable *table, unsigned long
saddr,
hashptr = table->hash_table[hp];
if (s6addr == NULL) {
- s6addr = xmalloc(sizeof(struct in6_addr));
- memset(s6addr, 0, 16);
+ s6addr = xmallocz(sizeof(struct in6_addr));
sfree = 1;
}
if (d6addr == NULL) {
- d6addr = xmalloc(sizeof(struct in6_addr));
- memset(d6addr, 0, 16);
+ d6addr = xmallocz(sizeof(struct in6_addr));
dfree = 1;
}
while (hashptr != NULL) {
--
1.7.8.4
Show replies by date
On Sun, 13 May 2012 21:44:30 +0200
Vitezslav Samel <vitezslav(a)samel.cz> wrote:
Replace xmalloc() followed by memset( ..., 0, ...) with xmallocz().
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/fltedit.c | 3 +--
src/ipfrag.c | 3 +--
src/othptab.c | 3 +--
src/tcptable.c | 9 +++------
4 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/fltedit.c b/src/fltedit.c
index f5746c9..90cf471 100644
--- a/src/fltedit.c
+++ b/src/fltedit.c
@@ -177,8 +177,7 @@ void update_hp_screen(struct filterent
*firstvisible, WINDOW * win)
int new_hp_entry(struct filterent **ftemp)
{
- *ftemp = xmalloc(sizeof(struct filterent));
- memset(*ftemp, 0, sizeof(struct filterent));
+ *ftemp = xmallocz(sizeof(struct filterent));
return 1;
}
int new_hp_entry is pretty stupid function witch never return failure.
Replace please this function only by xmallocz.