aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/reqrep
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-02 11:26:43 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-02 11:26:43 -0800
commitc3d8e75f2bb76b5bfafc589f860036cf42cfbaa0 (patch)
tree44c6cf24785864b4b83adb0fad9ec2b51f67d862 /src/protocol/reqrep
parentb921ef8889a86cce42bca28950e33ba11d28d78f (diff)
downloadnng-c3d8e75f2bb76b5bfafc589f860036cf42cfbaa0.tar.gz
nng-c3d8e75f2bb76b5bfafc589f860036cf42cfbaa0.tar.bz2
nng-c3d8e75f2bb76b5bfafc589f860036cf42cfbaa0.zip
Use new NNI_ALLOC_STRUCT macro. nni_msg_dup copies options too.
Diffstat (limited to 'src/protocol/reqrep')
-rw-r--r--src/protocol/reqrep/rep.c10
-rw-r--r--src/protocol/reqrep/req.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c
index 75cdaa2e..53007e12 100644
--- a/src/protocol/reqrep/rep.c
+++ b/src/protocol/reqrep/rep.c
@@ -51,11 +51,11 @@ nni_rep_create(void **repp, nni_socket *sock)
nni_rep_sock *rep;
int rv;
- if ((rep = nni_alloc(sizeof (*rep))) == NULL) {
+ if ((rep = NNI_ALLOC_STRUCT(rep)) == NULL) {
return (NNG_ENOMEM);
}
if ((rv = nni_mtx_init(&rep->mx)) != 0) {
- nni_free(rep, sizeof (*rep));
+ NNI_FREE_STRUCT(rep);
return (rv);
}
rep->ttl = 8; // Per RFC
@@ -65,7 +65,7 @@ nni_rep_create(void **repp, nni_socket *sock)
rep->btrace_len = 0;
if ((rv = nni_idhash_create(&rep->pipes)) != 0) {
nni_mtx_fini(&rep->mx);
- nni_free(rep, sizeof (*rep));
+ NNI_FREE_STRUCT(rep);
return (rv);
}
@@ -76,7 +76,7 @@ nni_rep_create(void **repp, nni_socket *sock)
if (rv != 0) {
nni_idhash_destroy(rep->pipes);
nni_mtx_fini(&rep->mx);
- nni_free(rep, sizeof (*rep));
+ NNI_FREE_STRUCT(rep);
return (rv);
}
*repp = rep;
@@ -97,7 +97,7 @@ nni_rep_destroy(void *arg)
if (rep->btrace != NULL) {
nni_free(rep->btrace, rep->btrace_len);
}
- nni_free(rep, sizeof (*rep));
+ NNI_FREE_STRUCT(rep);
}
diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c
index 611baadb..6c8f8543 100644
--- a/src/protocol/reqrep/req.c
+++ b/src/protocol/reqrep/req.c
@@ -55,16 +55,16 @@ nni_req_create(void **reqp, nni_socket *sock)
nni_req_sock *req;
int rv;
- if ((req = nni_alloc(sizeof (*req))) == NULL) {
+ if ((req = NNI_ALLOC_STRUCT(req)) == NULL) {
return (NNG_ENOMEM);
}
if ((rv = nni_mtx_init(&req->mx)) != 0) {
- nni_free(req, sizeof (*req));
+ NNI_FREE_STRUCT(req);
return (rv);
}
if ((rv = nni_cv_init(&req->cv, &req->mx)) != 0) {
nni_mtx_fini(&req->mx);
- nni_free(req, sizeof (*req));
+ NNI_FREE_STRUCT(req);
return (rv);
}
// this is "semi random" start for request IDs.
@@ -84,7 +84,7 @@ nni_req_create(void **reqp, nni_socket *sock)
if (rv != 0) {
nni_cv_fini(&req->cv);
nni_mtx_fini(&req->mx);
- nni_free(req, sizeof (*req));
+ NNI_FREE_STRUCT(req);
return (rv);
}
nni_thr_run(&req->resender);
@@ -107,7 +107,7 @@ nni_req_destroy(void *arg)
nni_thr_fini(&req->resender);
nni_cv_fini(&req->cv);
nni_mtx_fini(&req->mx);
- nni_free(req, sizeof (*req));
+ NNI_FREE_STRUCT(req);
}