static ngx_int_t
ngx_http_variable_server_addr(ngx_http_request_t *r,
    ngx_http_variable_value_t *v, uintptr_t data)
{
    ngx_str_t  s;
    u_char     addr[NGX_SOCKADDR_STRLEN];
    s.len = NGX_SOCKADDR_STRLEN;
    s.data = addr;
    if (ngx_http_server_addr(r, &s) != NGX_OK) {
        return NGX_ERROR;
    }
    s.data = ngx_pnalloc(r->pool, s.len);
    if (s.data == NULL) {
        return NGX_ERROR;
    }
    ngx_memcpy(s.data, addr, s.len);
    v->len = s.len;
    v->valid = 1;
    v->no_cacheable = 0;
    v->not_found = 0;
    v->data = s.data;
    return NGX_OK;
}
['static ngx_int_t\nngx_http_variable_server_addr(ngx_http_request_t *r,\n    ngx_http_variable_value_t *v, uintptr_t data)\n{\n    ngx_str_t  s;\n    u_char     addr[NGX_SOCKADDR_STRLEN];\n    s.len = NGX_SOCKADDR_STRLEN;\n    s.data = addr;\n    if (ngx_http_server_addr(r, &s) != NGX_OK) {\n        return NGX_ERROR;\n    }\n    s.data = ngx_pnalloc(r->pool, s.len);\n    if (s.data == NULL) {\n        return NGX_ERROR;\n    }\n    ngx_memcpy(s.data, addr, s.len);\n    v->len = s.len;\n    v->valid = 1;\n    v->no_cacheable = 0;\n    v->not_found = 0;\n    v->data = s.data;\n    return NGX_OK;\n}', 'ngx_int_t\nngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s)\n{\n    socklen_t             len;\n    ngx_uint_t            addr;\n    ngx_connection_t     *c;\n    u_char                sa[NGX_SOCKADDRLEN];\n    struct sockaddr_in   *sin;\n#if (NGX_HAVE_INET6)\n    ngx_uint_t            i;\n    struct sockaddr_in6  *sin6;\n#endif\n    c = r->connection;\n    switch (c->local_sockaddr->sa_family) {\n#if (NGX_HAVE_INET6)\n    case AF_INET6:\n        sin6 = (struct sockaddr_in6 *) c->local_sockaddr;\n        for (addr = 0, i = 0; addr == 0 && i < 16; i++) {\n            addr |= sin6->sin6_addr.s6_addr[i];\n        }\n        break;\n#endif\n    default:\n        sin = (struct sockaddr_in *) c->local_sockaddr;\n        addr = sin->sin_addr.s_addr;\n        break;\n    }\n    if (addr == 0) {\n        len = NGX_SOCKADDRLEN;\n        if (getsockname(c->fd, (struct sockaddr *) &sa, &len) == -1) {\n            ngx_connection_error(c, ngx_socket_errno, "getsockname() failed");\n            return NGX_ERROR;\n        }\n        c->local_sockaddr = ngx_palloc(r->connection->pool, len);\n        if (c->local_sockaddr == NULL) {\n            return NGX_ERROR;\n        }\n        c->local_socklen = len;\n        ngx_memcpy(c->local_sockaddr, &sa, len);\n    }\n    if (s == NULL) {\n        return NGX_OK;\n    }\n    s->len = ngx_sock_ntop(c->local_sockaddr, s->data, s->len, 0);\n    return NGX_OK;\n}', 'void *\nngx_pnalloc(ngx_pool_t *pool, size_t size)\n{\n    u_char      *m;\n    ngx_pool_t  *p;\n    if (size <= pool->max) {\n        p = pool->current;\n        do {\n            m = p->d.last;\n            if ((size_t) (p->d.end - m) >= size) {\n                p->d.last = m + size;\n                return m;\n            }\n            p = p->d.next;\n        } while (p);\n        return ngx_palloc_block(pool, size);\n    }\n    return ngx_palloc_large(pool, size);\n}']