htp_tx_t *htp_tx_create(htp_connp_t *connp) { htp_tx_t *tx = calloc(1, sizeof (htp_tx_t)); if (tx == NULL) return NULL; tx->connp = connp; tx->conn = connp->conn; tx->cfg = connp->cfg; tx->is_config_shared = HTP_CONFIG_SHARED; tx->request_protocol_number = HTP_PROTOCOL_UNKNOWN; tx->request_header_lines = htp_list_create(32); tx->request_headers = htp_table_create(32); tx->request_params = htp_table_create(32); tx->request_line_nul_offset = -1; tx->request_content_length = -1; tx->parsed_uri = calloc(1, sizeof (htp_uri_t)); tx->parsed_uri->port_number = -1; tx->parsed_uri_incomplete = calloc(1, sizeof (htp_uri_t)); tx->response_header_lines = htp_list_create(32); tx->response_headers = htp_table_create(32); tx->response_content_length = -1; return tx; }
htp_conn_t *htp_conn_create(void) { htp_conn_t *conn = calloc(1, sizeof (htp_conn_t)); if (conn == NULL) return NULL; conn->transactions = htp_list_create(16); if (conn->transactions == NULL) { free(conn); return NULL; } conn->messages = htp_list_create(8); if (conn->messages == NULL) { htp_list_destroy(conn->transactions); conn->transactions = NULL; free(conn); return NULL; } return conn; }
bstr_builder_t *bstr_builder_create() { bstr_builder_t *bb = calloc(1, sizeof (bstr_builder_t)); if (bb == NULL) return NULL; bb->pieces = htp_list_create(BSTR_BUILDER_DEFAULT_SIZE); if (bb->pieces == NULL) { free(bb); return NULL; } return bb; }