Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
26513b70
Commit
26513b70
authored
Apr 04, 2017
by
Luca Boccassi
Committed by
GitHub
Apr 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2494 from bjovke/master
Unnecessary dynamic memory allocation in zmq_poller_poll()
parents
5d5263ed
319eb27f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
zmq.cpp
src/zmq.cpp
+6
-11
No files found.
src/zmq.cpp
View file @
26513b70
...
@@ -757,10 +757,9 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
...
@@ -757,10 +757,9 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
// implement zmq_poll on top of zmq_poller
// implement zmq_poll on top of zmq_poller
int
rc
;
int
rc
;
zmq_poller_event_t
*
events
;
zmq_poller_event_t
*
events
;
zmq
::
socket_poller_t
poller
;
events
=
new
(
std
::
nothrow
)
zmq_poller_event_t
[
nitems_
];
events
=
new
(
std
::
nothrow
)
zmq_poller_event_t
[
nitems_
];
alloc_assert
(
events
);
alloc_assert
(
events
);
void
*
poller
=
zmq_poller_new
();
alloc_assert
(
poller
);
bool
repeat_items
=
false
;
bool
repeat_items
=
false
;
// Register sockets with poller
// Register sockets with poller
...
@@ -780,12 +779,11 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
...
@@ -780,12 +779,11 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
}
}
}
}
if
(
modify
)
{
if
(
modify
)
{
rc
=
zmq_poller_modify
(
poller
,
items_
[
i
].
socket
,
e
);
rc
=
zmq_poller_modify
(
&
poller
,
items_
[
i
].
socket
,
e
);
}
else
{
}
else
{
rc
=
zmq_poller_add
(
poller
,
items_
[
i
].
socket
,
NULL
,
e
);
rc
=
zmq_poller_add
(
&
poller
,
items_
[
i
].
socket
,
NULL
,
e
);
}
}
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
zmq_poller_destroy
(
&
poller
);
delete
[]
events
;
delete
[]
events
;
return
rc
;
return
rc
;
}
}
...
@@ -800,12 +798,11 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
...
@@ -800,12 +798,11 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
}
}
}
}
if
(
modify
)
{
if
(
modify
)
{
rc
=
zmq_poller_modify_fd
(
poller
,
items_
[
i
].
fd
,
e
);
rc
=
zmq_poller_modify_fd
(
&
poller
,
items_
[
i
].
fd
,
e
);
}
else
{
}
else
{
rc
=
zmq_poller_add_fd
(
poller
,
items_
[
i
].
fd
,
NULL
,
e
);
rc
=
zmq_poller_add_fd
(
&
poller
,
items_
[
i
].
fd
,
NULL
,
e
);
}
}
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
zmq_poller_destroy
(
&
poller
);
delete
[]
events
;
delete
[]
events
;
return
rc
;
return
rc
;
}
}
...
@@ -813,9 +810,8 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
...
@@ -813,9 +810,8 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
}
}
// Wait for events
// Wait for events
rc
=
zmq_poller_wait_all
(
poller
,
events
,
nitems_
,
timeout_
);
rc
=
zmq_poller_wait_all
(
&
poller
,
events
,
nitems_
,
timeout_
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
zmq_poller_destroy
(
&
poller
);
delete
[]
events
;
delete
[]
events
;
if
(
zmq_errno
()
==
ETIMEDOUT
)
{
if
(
zmq_errno
()
==
ETIMEDOUT
)
{
return
0
;
return
0
;
...
@@ -851,7 +847,6 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
...
@@ -851,7 +847,6 @@ inline int zmq_poller_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
}
}
// Cleanup
// Cleanup
zmq_poller_destroy
(
&
poller
);
delete
[]
events
;
delete
[]
events
;
return
rc
;
return
rc
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment