diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-04-15 19:10:18 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-04-15 19:10:18 +0000 |
commit | 1fa0fc14876357b7f5d36696166d33dc1159b294 (patch) | |
tree | 00553f761f24242c4660b5079ee7025863ee8d08 /src/or/connection.c | |
parent | 7df5caad0df1644770316d98a289be734029f4c5 (diff) | |
download | tor-1fa0fc14876357b7f5d36696166d33dc1159b294.tar.gz tor-1fa0fc14876357b7f5d36696166d33dc1159b294.zip |
Introduce a few unit tests (from older code), refactor compression setup/teardown
svn:r232
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 576e4962fe..20b29dfa2c 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -130,20 +130,10 @@ connection_t *connection_new(int type) { if (type == CONN_TYPE_AP || type == CONN_TYPE_EXIT) { if (buf_new(&conn->z_outbuf, &conn->z_outbuflen, &conn->z_outbuf_datalen) < 0) return NULL; - if (! (conn->compression = malloc(sizeof(z_stream)))) + if (! (conn->compression = compression_new())) return NULL; - if (! (conn->decompression = malloc(sizeof(z_stream)))) + if (! (conn->decompression = decompression_new())) return NULL; - memset(conn->compression, 0, sizeof(z_stream)); - memset(conn->decompression, 0, sizeof(z_stream)); - if (deflateInit(conn->compression, Z_DEFAULT_COMPRESSION) != Z_OK) { - log(LOG_ERR, "Error initializing zlib: %s", conn->compression->msg); - return NULL; - } - if (inflateInit(conn->decompression) != Z_OK) { - log(LOG_ERR, "Error initializing zlib: %s", conn->decompression->msg); - return NULL; - } } else { conn->compression = conn->decompression = NULL; } @@ -181,14 +171,8 @@ void connection_free(connection_t *conn) { } #ifdef USE_ZLIB if (conn->compression) { - if (inflateEnd(conn->decompression) != Z_OK) - log(LOG_ERR,"connection_free(): while closing zlib: %s", - conn->decompression->msg); - if (deflateEnd(conn->compression) != Z_OK) - log(LOG_ERR,"connection_free(): while closing zlib: %s", - conn->compression->msg); - free(conn->compression); - free(conn->decompression); + decompression_free(conn->decompression); + compression_free(conn->compression); buf_free(conn->z_outbuf); } #endif |