<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Hello,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">While reading through the source code for nginx I came across the following two lines in ngx_config.h </div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><div id="bloop_customfont" style="margin: 0px;">#define NGX_INT32_LEN   (sizeof("-2147483648") - 1)</div><div id="bloop_customfont" style="margin: 0px;">#define NGX_INT64_LEN   (sizeof("-9223372036854775808") - 1)</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">I was wondering if someone could explain the intention of these lines to me because it is not clear.  My understanding is that using sizeof() on a string will return the number of characters in that string.  Conversely, I get the feeling these lines are supposed to somehow act as replacements for INT32_MAX and INT64_MAX in stdint.h.</div></div><br><div class="" id="bloop_sign_1386026969782895104">Looking at code where these #define’s are used doesn’t really help clarify things either.  For example, in nginx.c there is:<span></span></div><div class="" id="bloop_sign_1386026969782895104"><br></div><div class="" id="bloop_sign_1386026969782895104"><div class="" id="bloop_sign_1386026969782895104">    var = ngx_alloc(sizeof(NGINX_VAR)</div><div class="" id="bloop_sign_1386026969782895104">                    + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2,</div><div class="" id="bloop_sign_1386026969782895104">                    cycle->log);</div><div class="" id="bloop_sign_1386026969782895104"><br></div><div class="" id="bloop_sign_1386026969782895104">The code clearly allocates memory, but it’s not clear why the allocation is a multiple of NGX_INT32_LEN (or why we’re adding 1, or 2 for that matter).</div><div class="" id="bloop_sign_1386026969782895104"><br></div><div class="" id="bloop_sign_1386026969782895104">Any direction would be much appreciated.</div><div class="" id="bloop_sign_1386026969782895104"><br></div><div class="" id="bloop_sign_1386026969782895104">- Dean</div></div></body></html>