diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-07-26 17:11:43 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-07-26 17:11:43 +0200 |
commit | 3613e17297f65f7ed860b298119cd8a2dbae3457 (patch) | |
tree | 1759606b0e95bcb0d904ed0f46484495fcff34a5 | |
parent | 1c81935ffc40d01403243f6ad9c65e4bbc8a0e96 (diff) | |
download | gnutls-3613e17297f65f7ed860b298119cd8a2dbae3457.tar.gz |
small optimizations.
-rw-r--r-- | lib/gnutls_buffers.c | 4 | ||||
-rw-r--r-- | lib/gnutls_record.c | 14 | ||||
-rw-r--r-- | lib/gnutls_record.h | 15 |
3 files changed, 17 insertions, 16 deletions
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 3b281f7bad..a327bbd981 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -180,7 +180,7 @@ _gnutls_dgram_read (gnutls_session_t session, mbuffer_st **bufel, ssize_t i, ret; uint8_t *ptr; struct timespec t1, t2; - size_t max_size = _gnutls_get_max_decrypted_data(session); + size_t max_size = get_max_decrypted_data(session); size_t recv_size = MAX_RECV_SIZE(session); gnutls_transport_ptr_t fd = session->internals.transport_recv_ptr; unsigned int diff; @@ -260,7 +260,7 @@ _gnutls_stream_read (gnutls_session_t session, mbuffer_st **bufel, { size_t left; ssize_t i = 0; - size_t max_size = _gnutls_get_max_decrypted_data(session); + size_t max_size = get_max_decrypted_data(session); uint8_t *ptr; gnutls_transport_ptr_t fd = session->internals.transport_recv_ptr; int ret; diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index 4795711aab..cc0d5f7ca5 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -933,18 +933,6 @@ cleanup: } -int _gnutls_get_max_decrypted_data(gnutls_session_t session) -{ -int ret; - - if (gnutls_compression_get (session) != GNUTLS_COMP_NULL || - session->internals.priorities.allow_large_records != 0) - ret = MAX_RECORD_RECV_SIZE(session) + EXTRA_COMP_SIZE; - else - ret = MAX_RECORD_RECV_SIZE(session); - - return ret; -} /* Checks the record headers and returns the length, version and * content type. @@ -1193,7 +1181,7 @@ begin: /* We allocate the maximum possible to allow few compressed bytes to expand to a * full record. */ - t.size = _gnutls_get_max_decrypted_data(session); + t.size = get_max_decrypted_data(session); decrypted = _mbuffer_alloc(t.size, t.size); if (decrypted == NULL) return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); diff --git a/lib/gnutls_record.h b/lib/gnutls_record.h index 6e86ed5947..ef45431b09 100644 --- a/lib/gnutls_record.h +++ b/lib/gnutls_record.h @@ -45,6 +45,19 @@ _gnutls_send_int (gnutls_session_t session, content_type_t type, ssize_t _gnutls_recv_int (gnutls_session_t session, content_type_t type, gnutls_handshake_description_t, uint8_t * data, size_t sizeofdata, void* seq, unsigned int ms); -int _gnutls_get_max_decrypted_data(gnutls_session_t session); + +inline +static int get_max_decrypted_data(gnutls_session_t session) +{ +int ret; + + if (gnutls_compression_get (session) != GNUTLS_COMP_NULL || + session->internals.priorities.allow_large_records != 0) + ret = MAX_RECORD_RECV_SIZE(session) + EXTRA_COMP_SIZE; + else + ret = MAX_RECORD_RECV_SIZE(session); + + return ret; +} #endif |