summaryrefslogtreecommitdiffstats
path: root/lib/msg.c
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.localdomain>2008-05-07 11:18:30 (GMT)
committerThomas Graf <tgr@lsx.localdomain>2008-05-07 11:18:30 (GMT)
commitb7c5bf98c4079304f78242d8b3c65451efc12b77 (patch)
tree055260585876f1e0e4602fb3719fc53d080d31fc /lib/msg.c
parentdc883cc14978fe2fc10f173c145ffc4d0c1178b0 (diff)
downloadlibnl-b7c5bf98c4079304f78242d8b3c65451efc12b77.zip
libnl-b7c5bf98c4079304f78242d8b3c65451efc12b77.tar.gz
libnl-b7c5bf98c4079304f78242d8b3c65451efc12b77.tar.bz2
Improve performance by using malloc() over calloc() in critical places
As pointed out by Regis Hanna, a considerable performance gain can be achieved by using malloc() over calloc() when allocating netlink message buffers. This is likely due to the fact that we use a complete page for each message.
Diffstat (limited to 'lib/msg.c')
-rw-r--r--lib/msg.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/msg.c b/lib/msg.c
index 3d4fbc6..c5cb7b4 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -372,10 +372,12 @@ static struct nl_msg *__nlmsg_alloc(size_t len)
if (!nm)
goto errout;
- nm->nm_nlh = calloc(1, len);
+ nm->nm_nlh = malloc(len);
if (!nm->nm_nlh)
goto errout;
+ memset(nm->nm_nlh, 0, sizeof(struct nlmsghdr));
+
nm->nm_protocol = -1;
nm->nm_size = len;
nm->nm_nlh->nlmsg_len = nlmsg_total_size(0);