Mercurial > hg > nginx
changeset 8191:7bd7c4e24951 quic
Macro for calculating size of varint.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 04 Mar 2020 23:24:51 +0300 |
parents | 2bc1f97c1c2d |
children | fb0879c65650 |
files | src/event/ngx_event_quic.c |
diffstat | 1 files changed, 3 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c Thu Mar 05 13:10:01 2020 +0300 +++ b/src/event/ngx_event_quic.c Wed Mar 04 23:24:51 2020 +0300 @@ -49,6 +49,8 @@ #define ngx_quic_write_uint32_aligned(p, s) \ (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t)) +#define ngx_quic_varint_len(value) \ + ((value) <= 63 ? 1 : (value) <= 16383 ? 2 : (value) <= 1073741823 ? 4 : 8) #if (NGX_DEBUG) @@ -349,12 +351,7 @@ u_char *start; if (p == NULL) { - if (crypto->len >= 64) { - return crypto->len + 4; - - } else { - return crypto->len + 3; - } // TODO: proper calculation of varint + return 3 + ngx_quic_varint_len(crypto->len) + crypto->len; } start = p;