static void env_clean_except_real(const char *const preserve_envs[])
{
ARRAY_TYPE(const_string) copy;
- const char *value, *const *envp;
+ const char *value, *env;
unsigned int i;
t_array_init(©, 16);
we t_strconcat() them above. */
env_clean();
- array_foreach(©, envp)
- env_put(*envp);
+ array_foreach_elem(©, env)
+ env_put(env);
}
void env_clean_except(const char *const preserve_envs[])
event_has_category_nonrecursive(struct event *event,
struct event_category *wanted_category)
{
- struct event_category *const *catp;
+ struct event_category *cat;
if (array_is_created(&event->categories)) {
- array_foreach(&event->categories, catp) {
- if (event_category_match(*catp, wanted_category))
+ array_foreach_elem(&event->categories, cat) {
+ if (event_category_match(cat, wanted_category))
return TRUE;
}
}
static void io_loop_timeouts_start_new(struct ioloop *ioloop)
{
- struct timeout *const *to_idx;
+ struct timeout *timeout;
if (array_count(&ioloop->timeouts_new) == 0)
return;
io_loop_time_refresh();
- array_foreach(&ioloop->timeouts_new, to_idx) {
- struct timeout *timeout= *to_idx;
+ array_foreach_elem(&ioloop->timeouts_new, timeout) {
i_assert(timeout->next_run.tv_sec == 0 &&
timeout->next_run.tv_usec == 0);
i_assert(!timeout->one_shot);
void io_loop_destroy(struct ioloop **_ioloop)
{
struct ioloop *ioloop = *_ioloop;
- struct timeout *const *to_idx;
+ struct timeout *to;
struct priorityq_item *item;
bool leaks = FALSE;
/* ->prev won't work unless loops are destroyed in create order */
i_assert(ioloop == current_ioloop);
if (array_is_created(&io_destroy_callbacks)) {
- io_destroy_callback_t *const *callbackp;
- array_foreach(&io_destroy_callbacks, callbackp)
- (*callbackp)(current_ioloop);
+ io_destroy_callback_t *callback;
+ array_foreach_elem(&io_destroy_callbacks, callback)
+ callback(current_ioloop);
}
io_loop_set_current(current_ioloop->prev);
}
i_assert(ioloop->io_pending_count == 0);
- array_foreach(&ioloop->timeouts_new, to_idx) {
- struct timeout *to = *to_idx;
+ array_foreach_elem(&ioloop->timeouts_new, to) {
const char *error = t_strdup_printf(
"Timeout leak: %p (%s:%u)", (void *)to->callback,
to->source_filename,
void io_loop_set_current(struct ioloop *ioloop)
{
- io_switch_callback_t *const *callbackp;
+ io_switch_callback_t *callback;
struct ioloop *prev_ioloop = current_ioloop;
if (ioloop == current_ioloop)
current_ioloop = ioloop;
if (array_is_created(&io_switch_callbacks)) {
- array_foreach(&io_switch_callbacks, callbackp)
- (*callbackp)(prev_ioloop);
+ array_foreach_elem(&io_switch_callbacks, callback)
+ callback(prev_ioloop);
}
}
static struct multiplex_ichannel *
get_channel(struct multiplex_istream *mstream, uint8_t cid)
{
- struct multiplex_ichannel **channelp;
+ struct multiplex_ichannel *channel;
i_assert(mstream != NULL);
- array_foreach_modifiable(&mstream->channels, channelp) {
- if (*channelp != NULL && (*channelp)->cid == cid)
- return *channelp;
+ array_foreach_elem(&mstream->channels, channel) {
+ if (channel != NULL && channel->cid == cid)
+ return channel;
}
return NULL;
}
static void propagate_error(struct multiplex_istream *mstream, int stream_errno)
{
- struct multiplex_ichannel **channelp;
- array_foreach_modifiable(&mstream->channels, channelp)
- if (*channelp != NULL)
- (*channelp)->istream.istream.stream_errno = stream_errno;
+ struct multiplex_ichannel *channel;
+ array_foreach_elem(&mstream->channels, channel)
+ if (channel != NULL)
+ channel->istream.istream.stream_errno = stream_errno;
}
static void propagate_eof(struct multiplex_istream *mstream)
{
- struct multiplex_ichannel **channelp;
- array_foreach_modifiable(&mstream->channels, channelp) {
- if (*channelp == NULL)
+ struct multiplex_ichannel *channel;
+ array_foreach_elem(&mstream->channels, channel) {
+ if (channel == NULL)
continue;
- (*channelp)->istream.istream.eof = TRUE;
+ channel->istream.istream.eof = TRUE;
if (mstream->remain > 0) {
- (*channelp)->istream.istream.stream_errno = EPIPE;
- io_stream_set_error(&(*channelp)->istream.iostream,
+ channel->istream.istream.stream_errno = EPIPE;
+ io_stream_set_error(&channel->istream.iostream,
"Unexpected EOF - %u bytes remaining in packet",
mstream->remain);
}
static void
i_stream_multiplex_ichannel_close(struct iostream_private *stream, bool close_parent)
{
- struct multiplex_ichannel *const *channelp;
+ struct multiplex_ichannel *arr_channel;
struct multiplex_ichannel *channel =
container_of(stream, struct multiplex_ichannel,
istream.iostream);
channel->closed = TRUE;
if (close_parent) {
- array_foreach(&channel->mstream->channels, channelp)
- if (*channelp != NULL && !(*channelp)->closed)
+ array_foreach_elem(&channel->mstream->channels, arr_channel)
+ if (arr_channel != NULL && !arr_channel->closed)
return;
i_stream_close(channel->mstream->parent);
}
static void i_stream_multiplex_try_destroy(struct multiplex_istream *mstream)
{
- struct multiplex_ichannel **channelp;
+ struct multiplex_ichannel *channel;
/* can't do anything until they are all closed */
- array_foreach_modifiable(&mstream->channels, channelp)
- if (*channelp != NULL)
+ array_foreach_elem(&mstream->channels, channel)
+ if (channel != NULL)
return;
i_stream_unref(&mstream->parent);
array_free(&mstream->channels);
event_call_callbacks(struct event *event, enum event_callback_type type,
struct failure_context *ctx, const char *fmt, va_list args)
{
- event_callback_t *const *callbackp;
+ event_callback_t *callback;
- array_foreach(&event_handlers, callbackp) {
+ array_foreach_elem(&event_handlers, callback) {
bool ret;
T_BEGIN {
- ret = (*callbackp)(event, type, ctx, fmt, args);
+ ret = callback(event, type, ctx, fmt, args);
} T_END;
if (!ret) {
/* event sending was stopped */
struct event_category *event_category_find_registered(const char *name)
{
- struct event_category *const *catp;
+ struct event_category *cat;
- array_foreach(&event_registered_categories_representative, catp) {
- if (strcmp((*catp)->name, name) == 0)
- return *catp;
+ array_foreach_elem(&event_registered_categories_representative, cat) {
+ if (strcmp(cat->name, name) == 0)
+ return cat;
}
return NULL;
}
static struct event_internal_category *
event_category_find_internal(const char *name)
{
- struct event_internal_category *const *internal;
+ struct event_internal_category *internal;
- array_foreach(&event_registered_categories_internal, internal) {
- if (strcmp((*internal)->name, name) == 0)
- return *internal;
+ array_foreach_elem(&event_registered_categories_internal, internal) {
+ if (strcmp(internal->name, name) == 0)
+ return internal;
}
return NULL;
event_category_register(struct event_category *category)
{
struct event_internal_category *internal = category->internal;
- event_category_callback_t *const *callbackp;
+ event_category_callback_t *callback;
bool allocated;
if (internal != NULL)
return &internal->representative;
}
- array_foreach(&event_category_callbacks, callbackp) T_BEGIN {
- (*callbackp)(&internal->representative);
+ array_foreach_elem(&event_category_callbacks, callback) T_BEGIN {
+ callback(&internal->representative);
} T_END;
return &internal->representative;
const struct event_category *category)
{
struct event_internal_category *internal = category->internal;
- struct event_category *const *categoryp;
+ struct event_category *cat;
/* make sure we're always looking for a representative */
i_assert(category == &internal->representative);
- array_foreach(&event->categories, categoryp) {
- if (*categoryp == category)
+ array_foreach_elem(&event->categories, cat) {
+ if (cat == category)
return TRUE;
}
return FALSE;
}
if (array_is_created(&event->categories)) {
- struct event_category *const *catp;
- array_foreach(&event->categories, catp) {
+ struct event_category *cat;
+ array_foreach_elem(&event->categories, cat) {
str_append_c(dest, '\t');
str_append_c(dest, EVENT_CODE_CATEGORY);
- str_append_tabescaped(dest, (*catp)->name);
+ str_append_tabescaped(dest, cat->name);
}
}
void lib_event_deinit(void)
{
- struct event_internal_category **internal;
+ struct event_internal_category *internal;
event_unset_global_debug_log_filter();
event_unset_global_debug_send_filter();
event->source_filename, event->source_linenum);
}
/* categories cannot be unregistered, so just free them here */
- array_foreach_modifiable(&event_registered_categories_internal, internal) {
- struct event_internal_category *cur = *internal;
-
- i_free(cur->name);
- i_free(cur);
+ array_foreach_elem(&event_registered_categories_internal, internal) {
+ i_free(internal->name);
+ i_free(internal);
}
array_free(&event_handlers);
array_free(&event_category_callbacks);
static struct multiplex_ochannel *
get_channel(struct multiplex_ostream *mstream, uint8_t cid)
{
- struct multiplex_ochannel **channelp;
+ struct multiplex_ochannel *channel;
i_assert(mstream != NULL);
- array_foreach_modifiable(&mstream->channels, channelp) {
- if (*channelp != NULL && (*channelp)->cid == cid)
- return *channelp;
+ array_foreach_elem(&mstream->channels, channel) {
+ if (channel != NULL && channel->cid == cid)
+ return channel;
}
return NULL;
}
static void propagate_error(struct multiplex_ostream *mstream, int stream_errno)
{
- struct multiplex_ochannel **channelp;
- array_foreach_modifiable(&mstream->channels, channelp)
- if (*channelp != NULL)
- (*channelp)->ostream.ostream.stream_errno = stream_errno;
+ struct multiplex_ochannel *channel;
+ array_foreach_elem(&mstream->channels, channel)
+ if (channel != NULL)
+ channel->ostream.ostream.stream_errno = stream_errno;
}
static struct multiplex_ochannel *get_next_channel(struct multiplex_ostream *mstream)
{
- struct multiplex_ochannel *channel = NULL;
- struct multiplex_ochannel **channelp;
+ struct multiplex_ochannel *oldest_channel = NULL;
+ struct multiplex_ochannel *channel;
uint64_t last_counter = mstream->send_counter;
- array_foreach_modifiable(&mstream->channels, channelp) {
- if (*channelp != NULL &&
- (*channelp)->last_sent_counter <= last_counter &&
- (*channelp)->buf->used > 0) {
- last_counter = (*channelp)->last_sent_counter;
- channel = *channelp;
+ array_foreach_elem(&mstream->channels, channel) {
+ if (channel != NULL &&
+ channel->last_sent_counter <= last_counter &&
+ channel->buf->used > 0) {
+ last_counter = channel->last_sent_counter;
+ oldest_channel = channel;
}
}
- return channel;
+ return oldest_channel;
}
static bool
/* Everything is flushed. See if one of the callbacks' flush callbacks
wants to write more data. */
- struct multiplex_ochannel **channelp;
+ struct multiplex_ochannel *channel;
bool unfinished = FALSE;
- array_foreach_modifiable(&mstream->channels, channelp) {
- if (*channelp != NULL && (*channelp)->ostream.callback != NULL) {
- ret = (*channelp)->ostream.callback((*channelp)->ostream.context);
+ array_foreach_elem(&mstream->channels, channel) {
+ if (channel != NULL && channel->ostream.callback != NULL) {
+ ret = channel->ostream.callback(channel->ostream.context);
if (ret < 0)
return -1;
if (ret == 0)
static void
o_stream_multiplex_ochannel_close(struct iostream_private *stream, bool close_parent)
{
- struct multiplex_ochannel *const *channelp;
+ struct multiplex_ochannel *arr_channel;
struct multiplex_ochannel *channel =
container_of(stream, struct multiplex_ochannel, ostream.iostream);
channel->closed = TRUE;
if (close_parent) {
- array_foreach(&channel->mstream->channels, channelp)
- if (*channelp !=NULL && !(*channelp)->closed)
+ array_foreach_elem(&channel->mstream->channels, arr_channel)
+ if (arr_channel != NULL && !arr_channel->closed)
return;
o_stream_close(channel->mstream->parent);
}
static void o_stream_multiplex_try_destroy(struct multiplex_ostream *mstream)
{
- struct multiplex_ochannel **channelp;
+ struct multiplex_ochannel *channel;
/* can't do anything until they are all closed */
- array_foreach_modifiable(&mstream->channels, channelp)
- if (*channelp != NULL)
+ array_foreach_elem(&mstream->channels, channel)
+ if (channel != NULL)
return;
i_assert(mstream->parent->real_stream->callback ==