37 #include "platform.hpp" 38 #if defined ZMQ_HAVE_WINDOWS 65 for (
unsigned short i = 0; i !=
count; ++i) {
87 pipes->insert (pipe_);
91 unsigned char c = *prefix_;
103 unsigned char oldc =
min;
109 for (
unsigned short i = 0; i !=
count; ++i)
112 next.table [oldc -
min] = oldp;
117 unsigned short old_count =
count;
122 for (
unsigned short i = old_count; i !=
count; i++)
123 next.table [i] = NULL;
127 unsigned short old_count =
count;
133 old_count * sizeof (
mtrie_t*));
134 for (
unsigned short i = 0; i !=
min - c; i++)
135 next.table [i] = NULL;
147 return next.node->add_helper (prefix_ + 1, size_ - 1, pipe_);
155 return next.table [c -
min]->add_helper (prefix_ + 1, size_ - 1, pipe_);
161 void (*func_) (
unsigned char *data_,
size_t size_,
void *arg_),
162 void *arg_,
bool call_on_uniq_)
164 unsigned char *buff = NULL;
165 rm_helper (pipe_, &buff, 0, 0, func_, arg_, call_on_uniq_);
170 size_t buffsize_,
size_t maxbuffsize_,
171 void (*func_) (
unsigned char *data_,
size_t size_,
void *arg_),
172 void *arg_,
bool call_on_uniq_)
176 if (!call_on_uniq_ ||
pipes->empty ()) {
177 func_ (*buff_, buffsize_, arg_);
180 if (
pipes->empty ()) {
186 if (buffsize_ >= maxbuffsize_) {
187 maxbuffsize_ = buffsize_ + 256;
188 *buff_ = (
unsigned char*) realloc (*buff_, maxbuffsize_);
198 (*buff_) [buffsize_] =
min;
200 next.node->rm_helper (pipe_, buff_, buffsize_, maxbuffsize_,
201 func_, arg_, call_on_uniq_);
204 if (
next.node->is_redundant ()) {
216 unsigned char new_min =
min +
count - 1;
218 unsigned char new_max =
min;
219 for (
unsigned short c = 0; c !=
count; c++) {
220 (*buff_) [buffsize_] =
min + c;
221 if (
next.table [c]) {
222 next.table [c]->rm_helper (pipe_, buff_, buffsize_ + 1,
223 maxbuffsize_, func_, arg_, call_on_uniq_);
226 if (
next.table [c]->is_redundant ()) {
240 if (c +
min < new_min)
242 if (c + min > new_max)
272 if (new_min >
min || new_max <
min + count - 1) {
281 count = new_max - new_min + 1;
285 memmove (
next.table, old_table + (new_min -
min),
295 return rm_helper (prefix_, size_, pipe_);
303 pipes_t::size_type erased =
pipes->erase (pipe_);
305 if (
pipes->empty ()) {
312 unsigned char c = *prefix_;
322 bool ret = next_node->
rm_helper (prefix_ + 1, size_ - 1, pipe_);
345 for (i = 0; i <
count; ++i)
360 for (i = 1; i <
count; ++i)
370 memmove (
next.table, old_table + i, sizeof (
mtrie_t*) * count);
377 for (i = 1; i <
count; ++i)
378 if (
next.table [count - 1 - i])
386 memmove (
next.table, old_table, sizeof (
mtrie_t*) * count);
396 void (*func_) (
pipe_t *pipe_,
void *arg_),
void *arg_)
402 if (current->
pipes) {
403 for (pipes_t::iterator it = current->
pipes->begin ();
404 it != current->
pipes->end (); ++it)
413 if (current->
count == 0)
417 if (current->
count == 1) {
418 if (data_ [0] != current->
min)
427 if (data_ [0] < current->
min || data_ [0] >=
432 current = current->
next.
table [data_ [0] - current->
min];
bool is_redundant() const
void match(unsigned char *data_, size_t size_, void(*func_)(zmq::pipe_t *pipe_, void *arg_), void *arg_)
#define LIBZMQ_DELETE(p_object)
union zmq::mtrie_t::@48 next
unsigned short live_nodes
bool add(unsigned char *prefix_, size_t size_, zmq::pipe_t *pipe_)
void rm_helper(zmq::pipe_t *pipe_, unsigned char **buff_, size_t buffsize_, size_t maxbuffsize_, void(*func_)(unsigned char *data_, size_t size_, void *arg_), void *arg_, bool call_on_uniq_)
void rm(zmq::pipe_t *pipe_, void(*func_)(unsigned char *data_, size_t size_, void *arg_), void *arg_, bool call_on_uniq_)
bool add_helper(unsigned char *prefix_, size_t size_, zmq::pipe_t *pipe_)
std::set< zmq::pipe_t * > pipes_t