Skip to content

Commit

Permalink
remove using of dynamic cast
Browse files Browse the repository at this point in the history
  • Loading branch information
somdoron committed Feb 17, 2016
1 parent b168e10 commit 352ae14
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/socket_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,

alloc_assert (s);

mailbox_t *mailbox = dynamic_cast<mailbox_t*> (s->mailbox);

if (mailbox != NULL && mailbox->get_fd () == retired_fd) {
if (s->mailbox == NULL) {
s->destroyed = true;
LIBZMQ_DELETE(s);
return NULL;
Expand Down Expand Up @@ -200,17 +198,24 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_, bool

if (thread_safe)
mailbox = new mailbox_safe_t(&sync);
else
mailbox = new mailbox_t();
else {
mailbox_t *m = new mailbox_t();
if (m->get_fd () != retired_fd)
mailbox = m;
else {
LIBZMQ_DELETE (m);
mailbox = NULL;
}
}
}

zmq::socket_base_t::~socket_base_t ()
{
LIBZMQ_DELETE(mailbox);
if (mailbox)
LIBZMQ_DELETE(mailbox);

if (reaper_signaler) {
if (reaper_signaler)
LIBZMQ_DELETE(reaper_signaler);
}

stop_monitor ();
zmq_assert (destroyed);
Expand Down

0 comments on commit 352ae14

Please sign in to comment.