summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@bisdn.de>2022-06-24 12:27:40 (GMT)
committerJonas Gorski <jonas.gorski@bisdn.de>2022-07-06 15:34:09 (GMT)
commit25d42a4f3c7daa5e14f174a31f14c4e1f2289e46 (patch)
tree8a8e0c8a6ebc894fcb770e53d04488b0d311b872 /lib
parent0c0aee829c1d2d468d89eda75d38e7490e4de575 (diff)
downloadlibnl-25d42a4f3c7daa5e14f174a31f14c4e1f2289e46.zip
libnl-25d42a4f3c7daa5e14f174a31f14c4e1f2289e46.tar.gz
libnl-25d42a4f3c7daa5e14f174a31f14c4e1f2289e46.tar.bz2
addr: allow constructing all-zero addresses
Allow easy contruction of all-zero addresses by not passing a buf to copy. Since the object is allocated with calloc, the address data will default to all-zero, and only the length needs to be set. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/addr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/addr.c b/lib/addr.c
index ab4bf22..d0b5f33 100644
--- a/lib/addr.c
+++ b/lib/addr.c
@@ -226,7 +226,7 @@ struct nl_addr *nl_addr_build(int family, const void *buf, size_t size)
addr->a_prefixlen = size*8;
}
- if (size)
+ if (size && buf)
memcpy(addr->a_addr, buf, size);
return addr;