ESL_DECLARE(void) esl_event_destroy(esl_event_t **event) { esl_event_t *ep = *event; esl_event_header_t *hp, *this; if (ep) { for (hp = ep->headers; hp;) { this = hp; hp = hp->next; FREE(this->name); if (this->idx) { int i = 0; for (i = 0; i < this->idx; i++) { FREE(this->array[i]); } FREE(this->array); } FREE(this->value); #ifdef ESL_EVENT_RECYCLE if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != ESL_SUCCESS) { FREE(this); } #else FREE(this); #endif } FREE(ep->body); FREE(ep->subclass_name); #ifdef ESL_EVENT_RECYCLE if (esl_queue_trypush(EVENT_RECYCLE_QUEUE, ep) != ESL_SUCCESS) { FREE(ep); } #else FREE(ep); #endif } *event = NULL; }
ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const char *header_name, const char *val) { esl_event_header_t *hp, *lp = NULL, *tp; esl_status_t status = ESL_FALSE; int x = 0; esl_ssize_t hlen = -1; unsigned long hash = 0; tp = event->headers; while (tp) { hp = tp; tp = tp->next; x++; esl_assert(x < 1000000); hash = esl_ci_hashfunc_default(header_name, &hlen); if ((!hp->hash || hash == hp->hash) && (hp->name && !strcasecmp(header_name, hp->name)) && (esl_strlen_zero(val) || !strcmp(hp->value, val))) { if (lp) { lp->next = hp->next; } else { event->headers = hp->next; } if (hp == event->last_header || !hp->next) { event->last_header = lp; } FREE(hp->name); if (hp->idx) { int i = 0; hp->value = NULL; for (i = 0; i < hp->idx; i++) { FREE(hp->array[i]); } FREE(hp->array); } FREE(hp->value); memset(hp, 0, sizeof(*hp)); #ifdef ESL_EVENT_RECYCLE if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != ESL_SUCCESS) { FREE(hp); } #else FREE(hp); #endif status = ESL_SUCCESS; } else { lp = hp; } } return status; }