void hash_table_print_info(struct hash_table *hash) { int collisions; collisions=hash_table_get_collisions(hash); printf("Size: %d\n",hash_table_get_size(hash)); printf("Used: %d\n",hash_table_get_used(hash)); printf("Load: %.3f\n",hash_table_get_load(hash)); printf("Collisions: %d\n",collisions); printf("Collision Rate: %.3f\n",(float)collisions/(float)hash->used); }
void mime_unalloc(hash_t *h) { hash_node_t *node; size_t i; for (i = 0; i < hash_table_get_size(h); i++) { node = h->nodes[i]; while(node) { free(node->data); node->data = NULL; node = node->next; } } hash_table_destroy(h); }
void calipso_socket_unalloc(calipso_socket_t *socket) { size_t i; if (socket->server) { hash_node_t* node; for (i = 0; i < hash_table_get_size(socket->server); ++i) { for (node = socket->server->nodes[i]; node != NULL; node = node->next) { printf("unalloc server %s \n", node->key); calipso_server_unalloc(node->data); } } hash_table_destroy(socket->server); } if (socket->config) { list_delete(socket->config); free(socket->config); } #ifdef USE_SSL if (socket->ssl_ctx) { SSL_CTX_free(socket->ssl_ctx); } #endif if (socket->event) { cpo_event_unalloc(socket->event); } if (socket->client) { queue_delete(socket->client); free(socket->client); } free(socket); }
int calipso_reply_send_header(calipso_reply_t *reply) { int i; hash_node_t *node; hash_t * hash = reply->header; struct chunk_ctx *ctx_header = chunk_ctx_alloc(reply->pool); u_int16_t status = calipso_reply_get_status(reply); const char *message = calipso_http_status_get_message(status); /* First we will have to send the status code */ chunk_ctx_printf(reply->pool, ctx_header, "HTTP/1.1 %d %s\r\n", status, message); for (i = 0; i < hash_table_get_size(hash); i++) { node = hash->nodes[i]; while(node) { chunk_ctx_printf(reply->pool, ctx_header, "%s: %s\r\n", node->key, (char *)node->data); #ifdef DEBUG_HEADER TRACE("HEADER_LINE %s: %s\n", node->key, (char *)node->data); #endif node = node->next; } } chunk_ctx_append(reply->pool, ctx_header, "\r\n" , 2); CNUNKS_ADD_HEAD_CTX(reply->out_filter, ctx_header); reply->bytes_to_send = reply->out_filter->total_bytes; //calipso_reply_get_replybuf_size(reply); calipso_reply_set_replybuf_size(reply, reply->out_filter->total_bytes); return (1); }