Dean Pucsek dean at
Mon Dec 2 23:44:53 UTC 2013


While reading through the source code for nginx I came across the following two lines in ngx_config.h 

#define NGX_INT32_LEN   (sizeof("-2147483648") - 1)
#define NGX_INT64_LEN   (sizeof("-9223372036854775808") - 1)

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.

Looking at code where these #define’s are used doesn’t really help clarify things either.  For example, in nginx.c there is:

    var = ngx_alloc(sizeof(NGINX_VAR)
                    + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2,

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).

Any direction would be much appreciated.

- Dean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list