aboutsummaryrefslogtreecommitdiff
path: root/src/core/message.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-07-20 13:42:13 -0700
committerGarrett D'Amore <garrett@damore.org>2018-07-24 07:57:39 -0700
commitccc24a8e508131a2226474642a038baaa2cbcc8c (patch)
tree7029f7668fe3e1a9899da57bf6c1e60e0394bacb /src/core/message.c
parent9b9526e4a643d36d9c66f2254f00df7298e5562f (diff)
downloadnng-ccc24a8e508131a2226474642a038baaa2cbcc8c.tar.gz
nng-ccc24a8e508131a2226474642a038baaa2cbcc8c.tar.bz2
nng-ccc24a8e508131a2226474642a038baaa2cbcc8c.zip
fixes #605 NNI_ALLOC_STRUCT/NNI_ALLOC_STRUCTS should zero memory
Diffstat (limited to 'src/core/message.c')
-rw-r--r--src/core/message.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/message.c b/src/core/message.c
index ba3c0e84..f17240a4 100644
--- a/src/core/message.c
+++ b/src/core/message.c
@@ -136,7 +136,7 @@ nni_chunk_grow(nni_chunk *ch, size_t newsz, size_t headwanted)
newsz = ch->ch_cap - headroom;
}
- if ((newbuf = nni_alloc(newsz + headwanted)) == NULL) {
+ if ((newbuf = nni_zalloc(newsz + headwanted)) == NULL) {
return (NNG_ENOMEM);
}
// Copy all the data, but not header or trailer.
@@ -152,7 +152,7 @@ nni_chunk_grow(nni_chunk *ch, size_t newsz, size_t headwanted)
// the backing store. In this case, we just check against the
// allocated capacity and grow, or don't grow.
if ((newsz + headwanted) >= ch->ch_cap) {
- if ((newbuf = nni_alloc(newsz + headwanted)) == NULL) {
+ if ((newbuf = nni_zalloc(newsz + headwanted)) == NULL) {
return (NNG_ENOMEM);
}
nni_free(ch->ch_buf, ch->ch_cap);
@@ -215,7 +215,7 @@ nni_chunk_trim(nni_chunk *ch, size_t len)
static int
nni_chunk_dup(nni_chunk *dst, const nni_chunk *src)
{
- if ((dst->ch_buf = nni_alloc(src->ch_cap)) == NULL) {
+ if ((dst->ch_buf = nni_zalloc(src->ch_cap)) == NULL) {
return (NNG_ENOMEM);
}
dst->ch_cap = src->ch_cap;
@@ -387,7 +387,7 @@ nni_msg_dup(nni_msg **dup, const nni_msg *src)
}
NNI_LIST_FOREACH (&src->m_options, mo) {
- newmo = nni_alloc(sizeof(*newmo) + mo->mo_sz);
+ newmo = nni_zalloc(sizeof(*newmo) + mo->mo_sz);
if (newmo == NULL) {
nni_msg_free(m);
return (NNG_ENOMEM);
@@ -436,7 +436,7 @@ nni_msg_setopt(nni_msg *m, int opt, const void *val, size_t sz)
break;
}
}
- if ((newmo = nni_alloc(sizeof(*newmo) + sz)) == NULL) {
+ if ((newmo = nni_zalloc(sizeof(*newmo) + sz)) == NULL) {
return (NNG_ENOMEM);
}
newmo->mo_val = ((char *) newmo + sizeof(*newmo));