aboutsummaryrefslogtreecommitdiff
path: root/src/core/message.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-16 16:27:22 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-16 16:27:22 -0800
commitac8415c24ffea645105c3859e814843e81c97f8a (patch)
tree7b64b4aab3de6ce5bdd69c3d5b7ead57f4a4b4e7 /src/core/message.c
parentb8f7236aa2928d70d9bff2e1071654982539eeda (diff)
downloadnng-ac8415c24ffea645105c3859e814843e81c97f8a.tar.gz
nng-ac8415c24ffea645105c3859e814843e81c97f8a.tar.bz2
nng-ac8415c24ffea645105c3859e814843e81c97f8a.zip
Start of event framework.
This compiles correctly, but doesn't actually deliver events yet. As part of this, I've made most of the initializables in nng safe to tear-down if uninitialized (or set to zero e.g. via calloc). This makes it loads easier to write the teardown on error code, since I can deinit everything, without worrying about which things have been initialized and which have not.
Diffstat (limited to 'src/core/message.c')
-rw-r--r--src/core/message.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/message.c b/src/core/message.c
index 778e7dfc..346570c9 100644
--- a/src/core/message.c
+++ b/src/core/message.c
@@ -363,13 +363,15 @@ nni_msg_free(nni_msg *m)
{
nni_msgopt *mo;
- nni_chunk_free(&m->m_header);
- nni_chunk_free(&m->m_body);
- while ((mo = nni_list_first(&m->m_options)) != NULL) {
- nni_list_remove(&m->m_options, mo);
- nni_free(mo, sizeof (*mo) + mo->mo_sz);
+ if (m != NULL) {
+ nni_chunk_free(&m->m_header);
+ nni_chunk_free(&m->m_body);
+ while ((mo = nni_list_first(&m->m_options)) != NULL) {
+ nni_list_remove(&m->m_options, mo);
+ nni_free(mo, sizeof (*mo) + mo->mo_sz);
+ }
+ NNI_FREE_STRUCT(m);
}
- NNI_FREE_STRUCT(m);
}