void arrayDestroy(Array * a) { assert(a != NULL); arrayClean(a); xfree(a); }
void httpHeaderClean(HttpHeader * hdr) { HttpHeaderPos pos = HttpHeaderInitPos; HttpHeaderEntry *e; assert(hdr); assert(hdr->owner > hoNone && hdr->owner <= hoReply); debug(55, 7) ("cleaning hdr: %p owner: %d\n", hdr, hdr->owner); /* * An unfortunate bug. The hdr->entries array is initialized * such that count is set to zero. httpHeaderClean() seems to * be called both when 'hdr' is created, and destroyed. Thus, * we accumulate a large number of zero counts for 'hdr' before * it is ever used. Can't think of a good way to fix it, except * adding a state variable that indicates whether or not 'hdr' * has been used. As a hack, just never count zero-sized header * arrays. */ if (0 != hdr->entries.count) statHistCount(&HttpHeaderStats[hdr->owner].hdrUCountDistr, hdr->entries.count); HttpHeaderStats[hdr->owner].destroyedCount++; HttpHeaderStats[hdr->owner].busyDestroyedCount += hdr->entries.count > 0; while ((e = httpHeaderGetEntry(hdr, &pos))) { /* tmp hack to try to avoid coredumps */ if (e->id >= HDR_ENUM_END) { debug(55, 0) ("httpHeaderClean BUG: entry[%d] is invalid (%d). Ignored.\n", (int) pos, e->id); } else { statHistCount(&HttpHeaderStats[hdr->owner].fieldTypeDistr, e->id); /* yes, this destroy() leaves us in an inconsistent state */ httpHeaderEntryDestroy(e); } } arrayClean(&hdr->entries); }