summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-02-01 19:20:07 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-02-01 19:20:07 +0300
commit6e67bee0f4f96ad0a7d1a231dfdae8431714c66a (patch)
treec422698ab3b7828f7346ca18e1f5a1b8305ed769 /src
parent8942550b13515e54aff9d682bec3da45ade26e18 (diff)
downloadunit-6e67bee0f4f96ad0a7d1a231dfdae8431714c66a.tar.gz
unit-6e67bee0f4f96ad0a7d1a231dfdae8431714c66a.tar.bz2
nxt_str_t changes.
Diffstat (limited to '')
-rw-r--r--src/nxt_application.c72
-rw-r--r--src/nxt_cycle.c94
-rw-r--r--src/nxt_errno.c26
-rw-r--r--src/nxt_file_name.c28
-rw-r--r--src/nxt_job_resolve.c10
-rw-r--r--src/nxt_parse.c56
-rw-r--r--src/nxt_poll.c18
-rw-r--r--src/nxt_python_wsgi.c56
-rw-r--r--src/nxt_sockaddr.c123
-rw-r--r--src/nxt_sprintf.c34
-rw-r--r--src/nxt_string.c79
-rw-r--r--src/nxt_string.h85
-rw-r--r--src/nxt_thread_time.c16
13 files changed, 350 insertions, 347 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index e87fcdf4..5e76613b 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -277,8 +277,8 @@ nxt_app_http_parse_request(nxt_app_request_t *r, u_char *buf, size_t size)
continue;
case NXT_DONE:
- r->body_preread.len = end - state.pos;
- r->body_preread.data = state.pos;
+ r->body_preread.length = end - state.pos;
+ r->body_preread.start = state.pos;
return NXT_OK;
@@ -326,8 +326,8 @@ nxt_app_http_parse_request_line(nxt_app_request_header_t *h, u_char *start,
}
}
- h->method.len = p - start;
- h->method.data = start;
+ h->method.length = p - start;
+ h->method.start = start;
start = p + 1;
@@ -337,8 +337,8 @@ nxt_app_http_parse_request_line(nxt_app_request_header_t *h, u_char *start,
return NXT_AGAIN;
}
- h->path.len = p - start;
- h->path.data = start;
+ h->path.length = p - start;
+ h->path.start = start;
start = p + 1;
@@ -346,8 +346,8 @@ nxt_app_http_parse_request_line(nxt_app_request_header_t *h, u_char *start,
return NXT_AGAIN;
}
- h->version.len = sizeof("HTTP/1.1") - 1;
- h->version.data = start;
+ h->version.length = sizeof("HTTP/1.1") - 1;
+ h->version.start = start;
p = start + sizeof("HTTP/1.1") - 1;
@@ -400,8 +400,8 @@ nxt_app_http_parse_field_name(nxt_app_request_header_t *h, u_char *start,
fld = &h->fields[h->fields_num];
- fld->name.len = p - start;
- fld->name.data = start;
+ fld->name.length = p - start;
+ fld->name.start = start;
return nxt_app_http_parse_field_value(h, p + 1, end, state);
@@ -441,10 +441,10 @@ nxt_app_http_parse_field_value(nxt_app_request_header_t *h, u_char *start,
fld = &h->fields[h->fields_num];
- fld->value.len = p - start;
- fld->value.data = start;
+ fld->value.length = p - start;
+ fld->value.start = start;
- fld->value.len -= (p[-1] == '\r');
+ fld->value.length -= (p[-1] == '\r');
h->fields_num++;
@@ -474,17 +474,17 @@ nxt_app_http_process_headers(nxt_app_request_t *r)
for (i = 0; i < r->header.fields_num; i++) {
fld = &r->header.fields[i];
- if (fld->name.len == sizeof(content_length)
- && nxt_memcasecmp(fld->name.data, content_length,
+ if (fld->name.length == sizeof(content_length)
+ && nxt_memcasecmp(fld->name.start, content_length,
sizeof(content_length)) == 0)
{
r->header.content_length = &fld->value;
- r->body_rest = nxt_off_t_parse(fld->value.data, fld->value.len);
+ r->body_rest = nxt_off_t_parse(fld->value.start, fld->value.length);
continue;
}
- if (fld->name.len == sizeof(content_type)
- && nxt_memcasecmp(fld->name.data, content_type,
+ if (fld->name.length == sizeof(content_type)
+ && nxt_memcasecmp(fld->name.start, content_type,
sizeof(content_type)) == 0)
{
r->header.content_type = &fld->value;
@@ -533,43 +533,43 @@ nxt_app_conn_update(nxt_thread_t *thr, nxt_event_conn_t *c, nxt_log_t *log)
nxt_int_t
-nxt_app_http_read_body(nxt_app_request_t *r, u_char *data, size_t len)
+nxt_app_http_read_body(nxt_app_request_t *r, u_char *start, size_t length)
{
size_t preread;
ssize_t n;
nxt_err_t err;
- if ((off_t) len > r->body_rest) {
- len = (size_t) r->body_rest;
+ if ((off_t) length > r->body_rest) {
+ length = (size_t) r->body_rest;
}
preread = 0;
- if (r->body_preread.len != 0) {
- preread = nxt_min(r->body_preread.len, len);
+ if (r->body_preread.length != 0) {
+ preread = nxt_min(r->body_preread.length, length);
- nxt_memcpy(data, r->body_preread.data, preread);
+ nxt_memcpy(start, r->body_preread.start, preread);
- r->body_preread.len -= preread;
- r->body_preread.data += preread;
+ r->body_preread.length -= preread;
+ r->body_preread.start += preread;
r->body_rest -= preread;
- len -= preread;
+ length -= preread;
}
- if (len == 0) {
+ if (length == 0) {
return NXT_OK;
}
- n = recv(r->event_conn->socket.fd, data + preread, len, 0);
+ n = recv(r->event_conn->socket.fd, start + preread, length, 0);
- if (nxt_slow_path(n < (ssize_t) len)) {
+ if (nxt_slow_path(n < (ssize_t) length)) {
if (n <= 0) {
err = (n == 0) ? 0 : nxt_socket_errno;
nxt_log_error(NXT_LOG_ERR, r->log, "recv(%d, %uz) failed %E",
- r->event_conn->socket.fd, len, err);
+ r->event_conn->socket.fd, length, err);
return NXT_ERROR;
}
@@ -587,7 +587,7 @@ nxt_app_http_read_body(nxt_app_request_t *r, u_char *data, size_t len)
nxt_int_t
-nxt_app_write(nxt_app_request_t *r, const u_char *data, size_t len)
+nxt_app_write(nxt_app_request_t *r, const u_char *data, size_t length)
{
void *start;
size_t free;
@@ -611,20 +611,20 @@ nxt_app_write(nxt_app_request_t *r, const u_char *data, size_t len)
for ( ;; ) {
free = nxt_buf_mem_free_size(&b->mem);
- if (free > len) {
- b->mem.free = nxt_cpymem(b->mem.free, data, len);
+ if (free > length) {
+ b->mem.free = nxt_cpymem(b->mem.free, data, length);
break;
}
b->mem.free = nxt_cpymem(b->mem.free, data, free);
data += free;
- len -= free;
+ length -= free;
*next = b;
next = &b->next;
- if (len == 0) {
+ if (length == 0) {
b = NULL;
break;
}
diff --git a/src/nxt_cycle.c b/src/nxt_cycle.c
index 7be529fa..c18089a4 100644
--- a/src/nxt_cycle.c
+++ b/src/nxt_cycle.c
@@ -868,8 +868,8 @@ nxt_cycle_conf_read_cmd(nxt_thread_t *thr, nxt_cycle_t *cycle)
p = *argv++;
- addr.len = nxt_strlen(p);
- addr.data = (u_char *) p;
+ addr.length = nxt_strlen(p);
+ addr.start = (u_char *) p;
sa = nxt_cycle_sockaddr_parse(&addr, cycle->mem_pool, thr->log);
@@ -967,16 +967,16 @@ static nxt_sockaddr_t *
nxt_cycle_sockaddr_parse(nxt_str_t *addr, nxt_mem_pool_t *mp, nxt_log_t *log)
{
u_char *p;
- size_t len;
+ size_t length;
- len = addr->len;
- p = addr->data;
+ length = addr->length;
+ p = addr->start;
- if (len >= 5 && nxt_memcmp(p, (u_char *) "unix:", 5) == 0) {
+ if (length >= 5 && nxt_memcmp(p, (u_char *) "unix:", 5) == 0) {
return nxt_cycle_sockaddr_unix_parse(addr, mp, log);
}
- if (len != 0 && *p == '[') {
+ if (length != 0 && *p == '[') {
return nxt_cycle_sockaddr_inet6_parse(addr, mp, log);
}
@@ -990,7 +990,7 @@ nxt_cycle_sockaddr_unix_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
{
#if (NXT_HAVE_UNIX_DOMAIN)
u_char *p;
- size_t len, socklen;
+ size_t length, socklen;
nxt_sockaddr_t *sa;
/*
@@ -1006,20 +1006,20 @@ nxt_cycle_sockaddr_unix_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
- offsetof(struct sockaddr_un, sun_path) - 1;
/* cutting "unix:" */
- len = addr->len - 5;
- p = addr->data + 5;
+ length = addr->length - 5;
+ p = addr->start + 5;
- if (len == 0) {
+ if (length == 0) {
nxt_log_emerg(log, "unix domain socket \"%V\" name is invalid", addr);
return NULL;
}
- if (len > max_len) {
+ if (length > max_len) {
nxt_log_emerg(log, "unix domain socket \"%V\" name is too long", addr);
return NULL;
}
- socklen = offsetof(struct sockaddr_un, sun_path) + len + 1;
+ socklen = offsetof(struct sockaddr_un, sun_path) + length + 1;
#if (NXT_LINUX)
@@ -1048,7 +1048,7 @@ nxt_cycle_sockaddr_unix_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
sa->type = SOCK_STREAM;
sa->u.sockaddr_un.sun_family = AF_UNIX;
- nxt_memcpy(sa->u.sockaddr_un.sun_path, p, len);
+ nxt_memcpy(sa->u.sockaddr_un.sun_path, p, length);
return sa;
@@ -1068,16 +1068,16 @@ nxt_cycle_sockaddr_inet6_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
{
#if (NXT_INET6)
u_char *p, *addr, *addr_end;
- size_t len;
+ size_t length;
nxt_int_t port;
nxt_mem_pool_t *mp;
nxt_sockaddr_t *sa;
struct in6_addr *in6_addr;
- len = addr->len - 1;
- p = addr->data + 1;
+ length = addr->length - 1;
+ p = addr->start + 1;
- addr_end = nxt_memchr(p, ']', len);
+ addr_end = nxt_memchr(p, ']', length);
if (addr_end == NULL) {
goto invalid_address;
@@ -1096,14 +1096,14 @@ nxt_cycle_sockaddr_inet6_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
}
p = addr_end + 1;
- len = (p + len) - p;
+ length = (p + length) - p;
- if (len == 0) {
+ if (length == 0) {
goto found;
}
if (*p == ':') {
- port = nxt_int_parse(p + 1, len - 1);
+ port = nxt_int_parse(p + 1, length - 1);
if (port >= 1 && port <= 65535) {
goto found;
@@ -1144,23 +1144,23 @@ nxt_cycle_sockaddr_inet_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
nxt_log_t *log)
{
u_char *p, *ip;
- size_t len;
+ size_t length;
in_addr_t s_addr;
nxt_int_t port;
nxt_sockaddr_t *sa;
s_addr = INADDR_ANY;
- len = addr->len;
- ip = addr->data;
+ length = addr->length;
+ ip = addr->start;
- p = nxt_memchr(ip, ':', len);
+ p = nxt_memchr(ip, ':', length);
if (p == NULL) {
/* single value port, or address */
- port = nxt_int_parse(ip, len);
+ port = nxt_int_parse(ip, length);
if (port > 0) {
/* "*:XX" */
@@ -1172,7 +1172,7 @@ nxt_cycle_sockaddr_inet_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
} else {
/* "x.x.x.x" */
- s_addr = nxt_inet_addr(ip, len);
+ s_addr = nxt_inet_addr(ip, length);
if (s_addr == INADDR_NONE) {
goto invalid_port;
@@ -1186,17 +1186,17 @@ nxt_cycle_sockaddr_inet_parse(nxt_str_t *addr, nxt_mem_pool_t *mp,
/* x.x.x.x:XX */
p++;
- len = (ip + len) - p;
- port = nxt_int_parse(p, len);
+ length = (ip + length) - p;
+ port = nxt_int_parse(p, length);
if (port < 1 || port > 65535) {
goto invalid_port;
}
- len = (p - 1) - ip;
+ length = (p - 1) - ip;
- if (len != 1 || ip[0] != '*') {
- s_addr = nxt_inet_addr(ip, len);
+ if (length != 1 || ip[0] != '*') {
+ s_addr = nxt_inet_addr(ip, length);
if (s_addr == INADDR_NONE) {
goto invalid_addr;
@@ -1356,7 +1356,7 @@ nxt_cycle_listen_socket_add(nxt_cycle_t *cycle, nxt_sockaddr_t *sa)
static nxt_int_t
nxt_cycle_hostname(nxt_thread_t *thr, nxt_cycle_t *cycle)
{
- size_t len;
+ size_t length;
char hostname[NXT_MAXHOSTNAMELEN + 1];
if (gethostname(hostname, NXT_MAXHOSTNAMELEN) != 0) {
@@ -1374,13 +1374,13 @@ nxt_cycle_hostname(nxt_thread_t *thr, nxt_cycle_t *cycle)
*/
hostname[NXT_MAXHOSTNAMELEN] = '\0';
- len = nxt_strlen(hostname);
- cycle->hostname.len = len;
+ length = nxt_strlen(hostname);
+ cycle->hostname.length = length;
- cycle->hostname.data = nxt_mem_nalloc(cycle->mem_pool, len);
+ cycle->hostname.start = nxt_mem_nalloc(cycle->mem_pool, length);
- if (cycle->hostname.data != NULL) {
- nxt_memcpy_lowcase(cycle->hostname.data, (u_char *) hostname, len);
+ if (cycle->hostname.start != NULL) {
+ nxt_memcpy_lowcase(cycle->hostname.start, (u_char *) hostname, length);
return NXT_OK;
}
@@ -1424,7 +1424,7 @@ nxt_cycle_log_file_add(nxt_cycle_t *cycle, nxt_str_t *name)
nxt_file_t *file;
nxt_file_name_str_t file_name;
- prefix = nxt_file_name_is_absolute(name->data) ? NULL : cycle->prefix;
+ prefix = nxt_file_name_is_absolute(name->start) ? NULL : cycle->prefix;
ret = nxt_file_name_create(cycle->mem_pool, &file_name, "%V%V%Z",
prefix, name);
@@ -1588,18 +1588,18 @@ nxt_cycle_listen_sockets_enable(nxt_task_t *task, nxt_cycle_t *cycle)
nxt_str_t *
nxt_current_directory(nxt_mem_pool_t *mp)
{
- size_t len;
+ size_t length;
u_char *p;
nxt_str_t *name;
char buf[NXT_MAX_PATH_LEN];
- len = nxt_dir_current(buf, NXT_MAX_PATH_LEN);
+ length = nxt_dir_current(buf, NXT_MAX_PATH_LEN);
- if (nxt_fast_path(len != 0)) {
- name = nxt_str_alloc(mp, len + 1);
+ if (nxt_fast_path(length != 0)) {
+ name = nxt_str_alloc(mp, length + 1);
if (nxt_fast_path(name != NULL)) {
- p = nxt_cpymem(name->data, buf, len);
+ p = nxt_cpymem(name->start, buf, length);
*p = '/';
return name;
@@ -1613,7 +1613,7 @@ nxt_current_directory(nxt_mem_pool_t *mp)
nxt_int_t
nxt_cycle_pid_file_create(nxt_file_name_t *pid_file, nxt_bool_t test)
{
- ssize_t len;
+ ssize_t length;
nxt_int_t n;
nxt_uint_t create;
nxt_file_t file;
@@ -1632,9 +1632,9 @@ nxt_cycle_pid_file_create(nxt_file_name_t *pid_file, nxt_bool_t test)
}
if (!test) {
- len = nxt_sprintf(pid, pid + sizeof(pid), "%PI%n", nxt_pid) - pid;
+ length = nxt_sprintf(pid, pid + sizeof(pid), "%PI%n", nxt_pid) - pid;
- if (nxt_file_write(&file, pid, len, 0) != len) {
+ if (nxt_file_write(&file, pid, length, 0) != length) {
return NXT_ERROR;
}
}
diff --git a/src/nxt_errno.c b/src/nxt_errno.c
index 64e043e5..9ac79936 100644
--- a/src/nxt_errno.c
+++ b/src/nxt_errno.c
@@ -37,7 +37,7 @@ nxt_strerror_start(void)
{
char *msg;
u_char *p;
- size_t size, len, n;
+ size_t size, length, n;
nxt_uint_t err, invalid;
/* The last entry. */
@@ -73,10 +73,10 @@ nxt_strerror_start(void)
continue;
}
- len = nxt_strlen(msg);
- size += len;
+ length = nxt_strlen(msg);
+ size += length;
- if (len == 0 /* HP-UX empty strings. */
+ if (length == 0 /* HP-UX empty strings. */
|| nxt_errno == NXT_EINVAL
|| nxt_memcmp(msg, "Unknown error", 13) == 0)
{
@@ -87,7 +87,7 @@ nxt_strerror_start(void)
#if (NXT_AIX)
if (nxt_memcmp(msg, "Error ", 6) == 0
- && nxt_memcmp(msg + len - 10, " occurred.", 9) == 0)
+ && nxt_memcmp(msg + length - 10, " occurred.", 9) == 0)
{
invalid++;
continue;
@@ -111,16 +111,16 @@ nxt_strerror_start(void)
for (err = 0; err < nxt_sys_nerr; err++) {
msg = strerror((int) err);
- len = nxt_strlen(msg);
+ length = nxt_strlen(msg);
- nxt_sys_errlist[err].len = len;
- nxt_sys_errlist[err].data = p;
+ nxt_sys_errlist[err].length = length;
+ nxt_sys_errlist[err].start = p;
- p = nxt_cpymem(p, msg, len);
+ p = nxt_cpymem(p, msg, length);
}
- nxt_sys_errlist[err].len = 13;
- nxt_sys_errlist[err].data = p;
+ nxt_sys_errlist[err].length = 13;
+ nxt_sys_errlist[err].start = p;
nxt_memcpy(p, "Unknown error", 13);
nxt_strerror = nxt_runtime_strerror;
@@ -146,7 +146,7 @@ nxt_runtime_strerror(nxt_err_t err, u_char *errstr, size_t size)
msg = &nxt_sys_errlist[n];
- size = nxt_min(size, msg->len);
+ size = nxt_min(size, msg->length);
- return nxt_cpymem(errstr, msg->data, size);
+ return nxt_cpymem(errstr, msg->start, size);
}
diff --git a/src/nxt_file_name.c b/src/nxt_file_name.c
index a59cd924..c8d8cad1 100644
--- a/src/nxt_file_name.c
+++ b/src/nxt_file_name.c
@@ -21,7 +21,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
const char *format, ...)
{
u_char ch, *p;
- size_t len;
+ size_t length;
va_list args;
nxt_str_t *v;
nxt_bool_t zero;
@@ -31,7 +31,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
va_start(args, format);
fmt = format;
zero = 0;
- len = 0;
+ length = 0;
for ( ;; ) {
ch = *fmt++;
@@ -39,7 +39,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
if (ch != '%') {
if (ch != '\0') {
- len++;
+ length++;
continue;
}
@@ -54,7 +54,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
v = va_arg(args, nxt_str_t *);
if (nxt_fast_path(v != NULL)) {
- len += v->len;
+ length += v->length;
}
continue;
@@ -65,14 +65,14 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
if (nxt_fast_path(p != NULL)) {
while (*p != '\0') {
p++;
- len++;
+ length++;
}
}
continue;
case '*':
- len += va_arg(args, u_int);
+ length += va_arg(args, u_int);
fmt++;
continue;
@@ -86,7 +86,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
if (nxt_fast_path(fn != NULL)) {
while (*fn != '\0') {
fn++;
- len += sizeof(nxt_file_name_t);
+ length += sizeof(nxt_file_name_t);
}
}
}
@@ -95,7 +95,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
case 'Z':
zero = 1;
- len++;
+ length++;
continue;
default:
@@ -105,13 +105,13 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
va_end(args);
- if (len == 0) {
+ if (length == 0) {
return NXT_ERROR;
}
- file_name->len = len - zero;
+ file_name->len = length - zero;
- fn = nxt_file_name_alloc(mp, len);
+ fn = nxt_file_name_alloc(mp, length);
if (nxt_slow_path(fn == NULL)) {
return NXT_ERROR;
}
@@ -143,7 +143,7 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
v = va_arg(args, nxt_str_t *);
if (nxt_fast_path(v != NULL)) {
- dst = nxt_file_name_add(dst, v->data, v->len);
+ dst = nxt_file_name_add(dst, v->start, v->length);
}
continue;
@@ -160,13 +160,13 @@ nxt_file_name_create(nxt_mem_pool_t *mp, nxt_file_name_str_t *file_name,
continue;
case '*':
- len += va_arg(args, u_int);
+ length += va_arg(args, u_int);
ch = *fmt++;
if (nxt_fast_path(ch == 's')) {
p = va_arg(args, u_char *);
- dst = nxt_file_name_add(dst, p, len);
+ dst = nxt_file_name_add(dst, p, length);
}
continue;
diff --git a/src/nxt_job_resolve.c b/src/nxt_job_resolve.c
index f0b34e2c..e220b085 100644
--- a/src/nxt_job_resolve.c
+++ b/src/nxt_job_resolve.c
@@ -12,7 +12,7 @@ nxt_job_resolve(nxt_job_resolve_t *jbr)
{
int err;
u_char *host;
- size_t len;
+ size_t length;
nxt_uint_t n;
nxt_mem_pool_t *mp;
nxt_sockaddr_t *sa;
@@ -25,19 +25,19 @@ nxt_job_resolve(nxt_job_resolve_t *jbr)
handler = jbr->error_handler;
res = NULL;
- len = jbr->name.len + 1;
+ length = jbr->name.length + 1;
- if (nxt_fast_path(len <= NXT_BUFSIZE)) {
+ if (nxt_fast_path(length <= NXT_BUFSIZE)) {
host = buf;
} else {
- host = nxt_mem_alloc(jbr->job.mem_pool, len);
+ host = nxt_mem_alloc(jbr->job.mem_pool, length);
if (nxt_slow_path(host == NULL)) {
goto fail;
}
}
- nxt_cpystrn(host, jbr->name.data, len);
+ nxt_cpystrn(host, jbr->name.start, length);
nxt_memzero(&hint, sizeof(struct addrinfo));
hint.ai_socktype = SOCK_STREAM;
diff --git a/src/nxt_parse.c b/src/nxt_parse.c
index 01dc8aa7..c0f8272e 100644
--- a/src/nxt_parse.c
+++ b/src/nxt_parse.c
@@ -13,12 +13,12 @@
*/
nxt_int_t
-nxt_int_parse(const u_char *p, size_t len)
+nxt_int_parse(const u_char *p, size_t length)
{
u_char c;
nxt_uint_t val;
- if (nxt_fast_path(len != 0)) {
+ if (nxt_fast_path(length != 0)) {
val = 0;
@@ -39,9 +39,9 @@ nxt_int_parse(const u_char *p, size_t len)
return -2;
}
- len--;
+ length--;
- } while (len != 0);
+ } while (length != 0);
return val;
}
@@ -56,12 +56,12 @@ nxt_int_parse(const u_char *p, size_t len)
*/
ssize_t
-nxt_size_t_parse(const u_char *p, size_t len)
+nxt_size_t_parse(const u_char *p, size_t length)
{
u_char c;
size_t val;
- if (nxt_fast_path(len != 0)) {
+ if (nxt_fast_path(length != 0)) {
val = 0;
@@ -82,9 +82,9 @@ nxt_size_t_parse(const u_char *p, size_t len)
return -2;
}
- len--;
+ length--;
- } while (len != 0);
+ } while (length != 0);
return val;
}
@@ -99,18 +99,18 @@ nxt_size_t_parse(const u_char *p, size_t len)
*/
ssize_t
-nxt_size_parse(const u_char *p, size_t len)
+nxt_size_parse(const u_char *p, size_t length)
{
u_char c, unit;
size_t val, max;
nxt_uint_t shift;
- if (nxt_fast_path(len != 0)) {
+ if (nxt_fast_path(length != 0)) {
- len--;
+ length--;
/* Upper case. */
- unit = p[len] & ~0x20;
+ unit = p[length] & ~0x20;
switch (unit) {
@@ -132,11 +132,11 @@ nxt_size_parse(const u_char *p, size_t len)
default:
max = NXT_SIZE_T_MAX;
shift = 0;
- len++;
+ length++;
break;
}
- if (nxt_fast_path(len != 0)) {
+ if (nxt_fast_path(length != 0)) {
val = 0;
@@ -157,9 +157,9 @@ nxt_size_parse(const u_char *p, size_t len)
return -2;
}
- len--;
+ length--;
- } while (len != 0);
+ } while (length != 0);
return val << shift;
}
@@ -175,12 +175,12 @@ nxt_size_parse(const u_char *p, size_t len)
*/
nxt_off_t
-nxt_off_t_parse(const u_char *p, size_t len)
+nxt_off_t_parse(const u_char *p, size_t length)
{
u_char c;
nxt_uoff_t val;
- if (nxt_fast_path(len != 0)) {
+ if (nxt_fast_path(length != 0)) {
val = 0;
@@ -201,9 +201,9 @@ nxt_off_t_parse(const u_char *p, size_t len)
return -2;
}
- len--;
+ length--;
- } while (len != 0);
+ } while (length != 0);
return val;
}
@@ -221,16 +221,16 @@ nxt_int_t
nxt_str_int_parse(nxt_str_t *s)
{
u_char c, *p;
- size_t len;
+ size_t length;
nxt_uint_t val;
- len = s->len;
+ length = s->length;
- if (nxt_slow_path(len == 0)) {
+ if (nxt_slow_path(length == 0)) {
return -1;
}
- p = s->data;
+ p = s->start;
val = 0;
do {
@@ -251,12 +251,12 @@ nxt_str_int_parse(nxt_str_t *s)
}
p++;
- len--;
+ length--;
- } while (len != 0);
+ } while (length != 0);
- s->len = len;
- s->data = p;
+ s->length = length;
+ s->start = p;
return val;
}
diff --git a/src/nxt_poll.c b/src/nxt_poll.c
index 6f6299b0..fd195261 100644
--- a/src/nxt_poll.c
+++ b/src/nxt_poll.c
@@ -454,8 +454,8 @@ nxt_poll_set_add(nxt_thread_t *thr, nxt_poll_event_set_t *ps,
lhq.key_hash = nxt_murmur_hash2(&ch->fd, sizeof(nxt_fd_t));
lhq.replace = 0;
- lhq.key.len = sizeof(nxt_fd_t);
- lhq.key.data = (u_char *) &ch->fd;
+ lhq.key.length = sizeof(nxt_fd_t);
+ lhq.key.start = (u_char *) &ch->fd;
lhq.value = phe;
lhq.proto = &nxt_poll_fd_hash_proto;
lhq.data = ps->poll_set;
@@ -501,8 +501,8 @@ nxt_poll_set_delete(nxt_thread_t *thr, nxt_poll_event_set_t *ps,
nxt_log_debug(thr->log, "poll delete event: fd:%d", ch->fd);
lhq.key_hash = nxt_murmur_hash2(&ch->fd, sizeof(nxt_fd_t));
- lhq.key.len = sizeof(nxt_fd_t);
- lhq.key.data = (u_char *) &ch->fd;
+ lhq.key.length = sizeof(nxt_fd_t);
+ lhq.key.start = (u_char *) &ch->fd;
lhq.proto = &nxt_poll_fd_hash_proto;
lhq.data = ps->poll_set;
@@ -682,8 +682,8 @@ nxt_poll_fd_hash_get(nxt_poll_event_set_t *ps, nxt_fd_t fd)
nxt_poll_hash_entry_t *phe;
lhq.key_hash = nxt_murmur_hash2(&fd, sizeof(nxt_fd_t));
- lhq.key.len = sizeof(nxt_fd_t);
- lhq.key.data = (u_char *) &fd;
+ lhq.key.length = sizeof(nxt_fd_t);
+ lhq.key.start = (u_char *) &fd;
lhq.proto = &nxt_poll_fd_hash_proto;
lhq.data = ps->poll_set;
@@ -706,7 +706,7 @@ nxt_poll_fd_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
phe = data;
- if (*(nxt_fd_t *) lhq->key.data == phe->fd) {
+ if (*(nxt_fd_t *) lhq->key.start == phe->fd) {
poll_set = lhq->data;
if (nxt_fast_path(phe->fd == poll_set[phe->index].fd)) {
@@ -740,8 +740,8 @@ nxt_poll_fd_hash_destroy(nxt_lvlhsh_t *lh)
}
lhq.key_hash = nxt_murmur_hash2(&phe->fd, sizeof(nxt_fd_t));
- lhq.key.len = sizeof(nxt_fd_t);
- lhq.key.data = (u_char *) &phe->fd;
+ lhq.key.length = sizeof(nxt_fd_t);
+ lhq.key.start = (u_char *) &phe->fd;
if (nxt_lvlhsh_delete(lh, &lhq) != NXT_OK) {
nxt_thread_log_alert("event fd %d not found in hash", phe->fd);
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c
index 404047c0..e983431b 100644
--- a/src/nxt_python_wsgi.c
+++ b/src/nxt_python_wsgi.c
@@ -605,8 +605,8 @@ nxt_python_get_environ(nxt_app_request_t *r)
return NULL;
}
- value = PyString_FromStringAndSize((char *) r->header.version.data,
- r->header.version.len);
+ value = PyString_FromStringAndSize((char *) r->header.version.start,
+ r->header.version.length);
if (nxt_slow_path(value == NULL)) {
nxt_log_error(NXT_LOG_ERR, r->log,
@@ -624,8 +624,8 @@ nxt_python_get_environ(nxt_app_request_t *r)
Py_DECREF(value);
- value = PyString_FromStringAndSize((char *) r->header.method.data,
- r->header.method.len);
+ value = PyString_FromStringAndSize((char *) r->header.method.start,
+ r->header.method.length);
if (nxt_slow_path(value == NULL)) {
nxt_log_error(NXT_LOG_ERR, r->log,
@@ -643,8 +643,8 @@ nxt_python_get_environ(nxt_app_request_t *r)
Py_DECREF(value);
- value = PyString_FromStringAndSize((char *) r->header.path.data,
- r->header.path.len);
+ value = PyString_FromStringAndSize((char *) r->header.path.start,
+ r->header.path.length);
if (nxt_slow_path(value == NULL)) {
nxt_log_error(NXT_LOG_ERR, r->log,
@@ -662,17 +662,17 @@ nxt_python_get_environ(nxt_app_request_t *r)
Py_DECREF(value);
- query = nxt_memchr(r->header.path.data, '?', r->header.path.len);
+ query = nxt_memchr(r->header.path.start, '?', r->header.path.length);
if (query != NULL) {
- value = PyString_FromStringAndSize((char *) r->header.path.data,
- query - r->header.path.data);
+ value = PyString_FromStringAndSize((char *) r->header.path.start,
+ query - r->header.path.start);
query++;
} else {
- value = PyString_FromStringAndSize((char *) r->header.path.data,
- r->header.path.len);
+ value = PyString_FromStringAndSize((char *) r->header.path.start,
+ r->header.path.length);
}
if (nxt_slow_path(value == NULL)) {
@@ -691,8 +691,8 @@ nxt_python_get_environ(nxt_app_request_t *r)
if (query != NULL) {
value = PyString_FromStringAndSize((char *) query,
- r->header.path.data
- + r->header.path.len - query);
+ r->header.path.start
+ + r->header.path.length - query);
if (nxt_slow_path(value == NULL)) {
nxt_log_error(NXT_LOG_ERR, r->log,
@@ -714,7 +714,7 @@ nxt_python_get_environ(nxt_app_request_t *r)
if (r->header.content_length != NULL) {
str = r->header.content_length;
- value = PyString_FromStringAndSize((char *) str->data, str->len);
+ value = PyString_FromStringAndSize((char *) str->start, str->length);
if (nxt_slow_path(value == NULL)) {
nxt_log_error(NXT_LOG_ERR, r->log,
@@ -736,7 +736,7 @@ nxt_python_get_environ(nxt_app_request_t *r)
if (r->header.content_type != NULL) {
str = r->header.content_type;
- value = PyString_FromStringAndSize((char *) str->data, str->len);
+ value = PyString_FromStringAndSize((char *) str->start, str->length);
if (nxt_slow_path(value == NULL)) {
nxt_log_error(NXT_LOG_ERR, r->log,
@@ -761,9 +761,9 @@ nxt_python_get_environ(nxt_app_request_t *r)
fld = &r->header.fields[i];
p = key + sizeof(prefix);
- for (n = 0; n < fld->name.len; n++, p++) {
+ for (n = 0; n < fld->name.length; n++, p++) {
- ch = fld->name.data[n];
+ ch = fld->name.start[n];
if (ch >= 'a' && ch <= 'z') {
*p = ch & ~0x20;
@@ -780,8 +780,8 @@ nxt_python_get_environ(nxt_app_request_t *r)
*p = '\0';
- value = PyString_FromStringAndSize((char *) fld->value.data,
- fld->value.len);
+ value = PyString_FromStringAndSize((char *) fld->value.start,
+ fld->value.length);
if (nxt_slow_path(PyDict_SetItemString(environ, (char *) key, value)
!= 0))
@@ -832,11 +832,11 @@ nxt_py_start_resp(PyObject *self, PyObject *args)
"the first argument is not a string");
}
- str.len = PyString_GET_SIZE(string);
- str.data = (u_char *) PyString_AS_STRING(string);
+ str.length = PyString_GET_SIZE(string);
+ str.start = (u_char *) PyString_AS_STRING(string);
p = nxt_cpymem(buf, resp, sizeof(resp) - 1);
- p = nxt_cpymem(p, str.data, str.len);
+ p = nxt_cpymem(p, str.start, str.length);
*p++ = '\r'; *p++ = '\n';
@@ -869,10 +869,10 @@ nxt_py_start_resp(PyObject *self, PyObject *args)
"all response headers names must be strings");
}
- str.len = PyString_GET_SIZE(string);
- str.data = (u_char *) PyString_AS_STRING(string);
+ str.length = PyString_GET_SIZE(string);
+ str.start = (u_char *) PyString_AS_STRING(string);
- p = nxt_cpymem(p, str.data, str.len);
+ p = nxt_cpymem(p, str.start, str.length);
*p++ = ':'; *p++ = ' ';
@@ -883,10 +883,10 @@ nxt_py_start_resp(PyObject *self, PyObject *args)
"all response headers values must be strings");
}
- str.len = PyString_GET_SIZE(string);
- str.data = (u_char *) PyString_AS_STRING(string);
+ str.length = PyString_GET_SIZE(string);
+ str.start = (u_char *) PyString_AS_STRING(string);
- p = nxt_cpymem(p, str.data, str.len);
+ p = nxt_cpymem(p, str.start, str.length);
*p++ = '\r'; *p++ = '\n';
}
diff --git a/src/nxt_sockaddr.c b/src/nxt_sockaddr.c
index 67e20b3f..2bb85730 100644
--- a/src/nxt_sockaddr.c
+++ b/src/nxt_sockaddr.c
@@ -17,7 +17,7 @@ static nxt_int_t nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs);
nxt_sockaddr_t *
-nxt_sockaddr_alloc(nxt_mem_pool_t *mp, socklen_t len)
+nxt_sockaddr_alloc(nxt_mem_pool_t *mp, socklen_t length)
{
nxt_sockaddr_t *sa;
@@ -28,10 +28,10 @@ nxt_sockaddr_alloc(nxt_mem_pool_t *mp, socklen_t len)
* If 128-bit alignment will be required then nxt_mem_malloc() and
* nxt_memzero() should be used instead.
*/
- sa = nxt_mem_zalloc(mp, offsetof(nxt_sockaddr_t, u) + len);
+ sa = nxt_mem_zalloc(mp, offsetof(nxt_sockaddr_t, u) + length);
if (nxt_fast_path(sa != NULL)) {
- nxt_socklen_set(sa, len);
+ nxt_socklen_set(sa, length);
}
return sa;
@@ -40,13 +40,13 @@ nxt_sockaddr_alloc(nxt_mem_pool_t *mp, socklen_t len)
nxt_sockaddr_t *
nxt_sockaddr_create(nxt_mem_pool_t *mp, struct sockaddr *sockaddr,
- socklen_t len)
+ socklen_t length)
{
size_t size, copy;
nxt_sockaddr_t *sa;
- size = len;
- copy = len;
+ size = length;
+ copy = length;
#if (NXT_HAVE_UNIX_DOMAIN)
@@ -110,7 +110,7 @@ nxt_sockaddr_create(nxt_mem_pool_t *mp, struct sockaddr *sockaddr,
#if (NXT_HAVE_UNIX_DOMAIN && NXT_OPENBSD)
- if (len == 0) {
+ if (length == 0) {
sa->u.sockaddr.sa_family = AF_UNIX;
}
@@ -124,15 +124,15 @@ nxt_sockaddr_create(nxt_mem_pool_t *mp, struct sockaddr *sockaddr,
nxt_sockaddr_t *
nxt_sockaddr_copy(nxt_mem_pool_t *mp, nxt_sockaddr_t *src)
{
- size_t len;
+ size_t length;
nxt_sockaddr_t *dst;
- len = offsetof(nxt_sockaddr_t, u) + nxt_socklen(src);
+ length = offsetof(nxt_sockaddr_t, u) + nxt_socklen(src);
- dst = nxt_mem_alloc(mp, len);
+ dst = nxt_mem_alloc(mp, length);
if (nxt_fast_path(dst != NULL)) {
- nxt_memcpy(dst, src, len);
+ nxt_memcpy(dst, src, length);
}
return dst;
@@ -164,21 +164,21 @@ nxt_getsockname(nxt_mem_pool_t *mp, nxt_socket_t s)
nxt_int_t
nxt_sockaddr_text(nxt_mem_pool_t *mp, nxt_sockaddr_t *sa, nxt_bool_t port)
{
- size_t len;
+ size_t length;
u_char *p;
u_char buf[NXT_SOCKADDR_STR_LEN + NXT_SOCKPORT_STR_LEN];
- len = NXT_SOCKADDR_STR_LEN + NXT_SOCKPORT_STR_LEN;
+ length = NXT_SOCKADDR_STR_LEN + NXT_SOCKPORT_STR_LEN;
- len = nxt_sockaddr_ntop(sa, buf, buf + len, port);
+ length = nxt_sockaddr_ntop(sa, buf, buf + length, port);
- p = nxt_mem_alloc(mp, len);
+ p = nxt_mem_alloc(mp, length);
if (nxt_fast_path(p != NULL)) {
sa->text = p;
- sa->text_len = len;
- nxt_memcpy(p, buf, len);
+ sa->text_len = length;
+ nxt_memcpy(p, buf, length);
return NXT_OK;
}
@@ -262,12 +262,12 @@ nxt_sockaddr_cmp(nxt_sockaddr_t *sa1, nxt_sockaddr_t *sa2)
case AF_UNIX:
{
- size_t len;
+ size_t length;
- len = nxt_socklen(sa1) - offsetof(struct sockaddr_un, sun_path);
+ length = nxt_socklen(sa1) - offsetof(struct sockaddr_un, sun_path);
if (nxt_memcmp(&sa1->u.sockaddr_un.sun_path,
- &sa2->u.sockaddr_un.sun_path, len)
+ &sa2->u.sockaddr_un.sun_path, length)
!= 0)
{
return 0;
@@ -343,12 +343,13 @@ nxt_sockaddr_ntop(nxt_sockaddr_t *sa, u_char *buf, u_char *end, nxt_bool_t port)
p = (u_char *) sa->u.sockaddr_un.sun_path;
if (p[0] == '\0') {
- int len;
+ int length;
/* Linux abstract socket address has no trailing zero. */
- len = nxt_socklen(sa) - offsetof(struct sockaddr_un, sun_path) - 1;
- p = nxt_sprintf(buf, end, "unix:\\0%*s", len, p + 1);
+ length = nxt_socklen(sa)
+ - offsetof(struct sockaddr_un, sun_path) - 1;
+ p = nxt_sprintf(buf, end, "unix:\\0%*s", length, p + 1);
} else {
p = nxt_sprintf(buf, end, "unix:%s", p);
@@ -462,19 +463,19 @@ void
nxt_job_sockaddr_parse(nxt_job_sockaddr_parse_t *jbs)
{
u_char *p;
- size_t len;
+ size_t length;
nxt_int_t ret;
nxt_work_handler_t handler;
nxt_job_set_name(&jbs->resolve.job, "job sockaddr parse");
- len = jbs->addr.len;
- p = jbs->addr.data;
+ length = jbs->addr.length;
+ p = jbs->addr.start;
- if (len > 6 && nxt_memcmp(p, (u_char *) "unix:", 5) == 0) {
+ if (length > 6 && nxt_memcmp(p, (u_char *) "unix:", 5) == 0) {
ret = nxt_job_sockaddr_unix_parse(jbs);
- } else if (len != 0 && *p == '[') {
+ } else if (length != 0 && *p == '[') {
ret = nxt_job_sockaddr_inet6_parse(jbs);
} else {
@@ -503,7 +504,7 @@ static nxt_int_t
nxt_job_sockaddr_unix_parse(nxt_job_sockaddr_parse_t *jbs)
{
#if (NXT_HAVE_UNIX_DOMAIN)
- size_t len, socklen;
+ size_t length, socklen;
u_char *path;
nxt_mem_pool_t *mp;
nxt_sockaddr_t *sa;
@@ -521,17 +522,17 @@ nxt_job_sockaddr_unix_parse(nxt_job_sockaddr_parse_t *jbs)
- offsetof(struct sockaddr_un, sun_path) - 1;
/* cutting "unix:" */
- len = jbs->addr.len - 5;
- path = jbs->addr.data + 5;
+ length = jbs->addr.length - 5;
+ path = jbs->addr.start + 5;
- if (len > max_len) {
+ if (length > max_len) {
nxt_thread_log_error(jbs->resolve.log_level,
"unix domain socket \"%V\" name is too long",
&jbs->addr);
return NXT_ERROR;
}
- socklen = offsetof(struct sockaddr_un, sun_path) + len + 1;
+ socklen = offsetof(struct sockaddr_un, sun_path) + length + 1;
#if (NXT_LINUX)
@@ -562,7 +563,7 @@ nxt_job_sockaddr_unix_parse(nxt_job_sockaddr_parse_t *jbs)
jbs->resolve.sockaddrs[0] = sa;
sa->u.sockaddr_un.sun_family = AF_UNIX;
- nxt_memcpy(sa->u.sockaddr_un.sun_path, path, len);
+ nxt_memcpy(sa->u.sockaddr_un.sun_path, path, length);
return NXT_OK;
}
@@ -586,16 +587,16 @@ nxt_job_sockaddr_inet6_parse(nxt_job_sockaddr_parse_t *jbs)
{
#if (NXT_INET6)
u_char *p, *addr, *addr_end;
- size_t len;
+ size_t length;
nxt_int_t port;
nxt_mem_pool_t *mp;
nxt_sockaddr_t *sa;
struct in6_addr *in6_addr;
- len = jbs->addr.len - 1;
- addr = jbs->addr.data + 1;
+ length = jbs->addr.length - 1;
+ addr = jbs->addr.start + 1;
- addr_end = nxt_memchr(addr, ']', len);
+ addr_end = nxt_memchr(addr, ']', length);
if (addr_end == NULL) {
goto invalid_address;
@@ -625,16 +626,16 @@ nxt_job_sockaddr_inet6_parse(nxt_job_sockaddr_parse_t *jbs)
}
p = addr_end + 1;
- len = (addr + len) - p;
+ length = (addr + length) - p;
- if (len == 0) {
+ if (length == 0) {
jbs->no_port = 1;
port = jbs->resolve.port;
goto found;
}
if (*p == ':') {
- port = nxt_int_parse(p + 1, len - 1);
+ port = nxt_int_parse(p + 1, length - 1);
if (port >= 1 && port <= 65535) {
port = htons((in_port_t) port);
@@ -678,7 +679,7 @@ static nxt_int_t
nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs)
{
u_char *p, *host;
- size_t len;
+ size_t length;
in_addr_t addr;
nxt_int_t port;
nxt_mem_pool_t *mp;
@@ -686,16 +687,16 @@ nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs)
addr = INADDR_ANY;
- len = jbs->addr.len;
- host = jbs->addr.data;
+ length = jbs->addr.length;
+ host = jbs->addr.start;
- p = nxt_memchr(host, ':', len);
+ p = nxt_memchr(host, ':', length);
if (p == NULL) {
/* single value port, address, or host name */
- port = nxt_int_parse(host, len);
+ port = nxt_int_parse(host, length);
if (port > 0) {
if (port < 1 || port > 65535) {
@@ -709,11 +710,11 @@ nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs)
} else {
jbs->no_port = 1;
- addr = nxt_inet_addr(host, len);
+ addr = nxt_inet_addr(host, length);
if (addr == INADDR_NONE) {
- jbs->resolve.name.len = len;
- jbs->resolve.name.data = host;
+ jbs->resolve.name.length = length;
+ jbs->resolve.name.start = host;
nxt_job_resolve(&jbs->resolve);
return NXT_AGAIN;
@@ -728,8 +729,8 @@ nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs)
/* x.x.x.x:XX or host:XX */
p++;
- len = (host + len) - p;
- port = nxt_int_parse(p, len);
+ length = (host + length) - p;
+ port = nxt_int_parse(p, length);
if (port < 1 || port > 65535) {
goto invalid_port;
@@ -737,14 +738,14 @@ nxt_job_sockaddr_inet_parse(nxt_job_sockaddr_parse_t *jbs)
port = htons((in_port_t) port);
- len = (p - 1) - host;
+ length = (p - 1) - host;
- if (len != 1 || host[0] != '*') {
- addr = nxt_inet_addr(host, len);
+ if (length != 1 || host[0] != '*') {
+ addr = nxt_inet_addr(host, length);
if (addr == INADDR_NONE) {
- jbs->resolve.name.len = len;
- jbs->resolve.name.data = host;
+ jbs->resolve.name.length = length;
+ jbs->resolve.name.start = host;
jbs->resolve.port = (in_port_t) port;
nxt_job_resolve(&jbs->resolve);
@@ -789,7 +790,7 @@ invalid_port:
in_addr_t
-nxt_inet_addr(u_char *buf, size_t len)
+nxt_inet_addr(u_char *buf, size_t length)
{
u_char c, *end;
in_addr_t addr;
@@ -799,7 +800,7 @@ nxt_inet_addr(u_char *buf, size_t len)
octet = 0;
dots = 0;
- end = buf + len;
+ end = buf + length;
while (buf < end) {
@@ -835,16 +836,16 @@ nxt_inet_addr(u_char *buf, size_t len)
#if (NXT_INET6)
nxt_int_t
-nxt_inet6_addr(struct in6_addr *in6_addr, u_char *buf, size_t len)
+nxt_inet6_addr(struct in6_addr *in6_addr, u_char *buf, size_t length)
{
u_char c, *addr, *zero_start, *ipv4, *dst, *src, *end;
nxt_uint_t digit, group, nibbles, groups_left;
- if (len == 0) {
+ if (length == 0) {
return NXT_ERROR;
}
- end = buf + len;
+ end = buf + length;
if (buf[0] == ':') {
buf++;
diff --git a/src/nxt_sprintf.c b/src/nxt_sprintf.c
index 837d2635..8aefaa50 100644
--- a/src/nxt_sprintf.c
+++ b/src/nxt_sprintf.c
@@ -101,7 +101,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args)
u_char *p;
int d;
double f, i;
- size_t len;
+ size_t length;
int64_t i64;
uint64_t ui64, frac;
nxt_str_t *v;
@@ -143,8 +143,8 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args)
v = va_arg(args, nxt_str_t *);
if (nxt_fast_path(v != NULL)) {
- len = v->len;
- p = v->data;
+ length = v->length;
+ p = v->start;
goto copy;
}
@@ -163,7 +163,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args)
continue;
case '*':
- len = va_arg(args, u_int);
+ length = va_arg(args, u_int);
fmt++;
@@ -380,13 +380,13 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args)
if (nxt_slow_path(isnan(f))) {
p = (u_char *) nan;
- len = sizeof(nan) - 1;
+ length = sizeof(nan) - 1;
goto copy;
} else if (nxt_slow_path(isinf(f))) {
p = (u_char *) infinity;
- len = sizeof(infinity) - 1;
+ length = sizeof(infinity) - 1;
goto copy;
}
@@ -555,7 +555,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args)
copy:
- buf = nxt_cpymem(buf, p, nxt_min((size_t) (end - buf), len));
+ buf = nxt_cpymem(buf, p, nxt_min((size_t) (end - buf), length));
continue;
}
@@ -567,7 +567,7 @@ static u_char *
nxt_integer(nxt_sprintf_t *spf, u_char *buf, uint64_t ui64)
{
u_char *p, *end;
- size_t len;
+ size_t length;
u_char temp[NXT_INT64_T_LEN];
p = temp + NXT_INT64_T_LEN;
@@ -652,8 +652,8 @@ nxt_integer(nxt_sprintf_t *spf, u_char *buf, uint64_t ui64)
if (spf->width != 0) {
- len = (temp + NXT_INT64_T_LEN) - p;
- end = buf + (spf->width - len);
+ length = (temp + NXT_INT64_T_LEN) - p;
+ end = buf + (spf->width - length);
end = nxt_min(end, spf->end);
while (buf < end) {
@@ -663,8 +663,8 @@ nxt_integer(nxt_sprintf_t *spf, u_char *buf, uint64_t ui64)
/* Number copying. */
- len = (temp + NXT_INT64_T_LEN) - p;
- end = buf + len;
+ length = (temp + NXT_INT64_T_LEN) - p;
+ end = buf + length;
end = nxt_min(end, spf->end);
while (buf < end) {
@@ -679,7 +679,7 @@ static u_char *
nxt_number(nxt_sprintf_t *spf, u_char *buf, double n)
{
u_char *p, *end;
- size_t len;
+ size_t length;
u_char temp[NXT_DOUBLE_LEN];
p = temp + NXT_DOUBLE_LEN;
@@ -692,8 +692,8 @@ nxt_number(nxt_sprintf_t *spf, u_char *buf, double n)
/* Zero or space padding. */
if (spf->width != 0) {
- len = (temp + NXT_DOUBLE_LEN) - p;
- end = buf + (spf->width - len);
+ length = (temp + NXT_DOUBLE_LEN) - p;
+ end = buf + (spf->width - length);
end = nxt_min(end, spf->end);
while (buf < end) {
@@ -703,9 +703,9 @@ nxt_number(nxt_sprintf_t *spf, u_char *buf, double n)
/* Number copying. */
- len = (temp + NXT_DOUBLE_LEN) - p;
+ length = (temp + NXT_DOUBLE_LEN) - p;
- end = buf + len;
+ end = buf + length;
end = nxt_min(end, spf->end);
while (buf < end) {
diff --git a/src/nxt_string.c b/src/nxt_string.c
index 45301e94..7e9d8fd4 100644
--- a/src/nxt_string.c
+++ b/src/nxt_string.c
@@ -8,16 +8,16 @@
nxt_str_t *
-nxt_str_alloc(nxt_mem_pool_t *mp, size_t len)
+nxt_str_alloc(nxt_mem_pool_t *mp, size_t length)
{
nxt_str_t *s;
- /* The string data is allocated aligned to be close to nxt_str_t. */
- s = nxt_mem_alloc(mp, sizeof(nxt_str_t) + len);
+ /* The string start is allocated aligned to be close to nxt_str_t. */
+ s = nxt_mem_alloc(mp, sizeof(nxt_str_t) + length);
if (nxt_fast_path(s != NULL)) {
- s->len = len;
- s->data = (u_char *) s + sizeof(nxt_str_t);
+ s->length = length;
+ s->start = (u_char *) s + sizeof(nxt_str_t);
}
return s;
@@ -36,25 +36,25 @@ nxt_str_dup(nxt_mem_pool_t *mp, nxt_str_t *dst, const nxt_str_t *src)
u_char *p;
if (dst == NULL) {
- /* The string data is allocated aligned to be close to nxt_str_t. */
- dst = nxt_mem_alloc(mp, sizeof(nxt_str_t) + src->len);
+ /* The string start is allocated aligned to be close to nxt_str_t. */
+ dst = nxt_mem_alloc(mp, sizeof(nxt_str_t) + src->length);
if (nxt_slow_path(dst == NULL)) {
return NULL;
}
p = (u_char *) dst;
p += sizeof(nxt_str_t);
- dst->data = p;
+ dst->start = p;
} else {
- dst->data = nxt_mem_nalloc(mp, src->len);
- if (nxt_slow_path(dst->data == NULL)) {
+ dst->start = nxt_mem_nalloc(mp, src->length);
+ if (nxt_slow_path(dst->start == NULL)) {
return NULL;
}
}
- nxt_memcpy(dst->data, src->data, src->len);
- dst->len = src->len;
+ nxt_memcpy(dst->start, src->start, src->length);
+ dst->length = src->length;
return dst;
}
@@ -73,10 +73,10 @@ nxt_str_copy(nxt_mem_pool_t *mp, const nxt_str_t *src)
{
char *p, *dst;
- dst = nxt_mem_align(mp, 2, src->len + 1);
+ dst = nxt_mem_align(mp, 2, src->length + 1);
if (nxt_fast_path(dst != NULL)) {
- p = nxt_cpymem(dst, src->data, src->len);
+ p = nxt_cpymem(dst, src->start, src->length);
*p = '\0';
}
@@ -85,26 +85,26 @@ nxt_str_copy(nxt_mem_pool_t *mp, const nxt_str_t *src)
void
-nxt_memcpy_lowcase(u_char *dst, const u_char *src, size_t len)
+nxt_memcpy_lowcase(u_char *dst, const u_char *src, size_t length)
{
u_char c;
- while (len != 0) {
+ while (length != 0) {
c = *src++;
*dst++ = nxt_lowcase(c);
- len--;
+ length--;
}
}
u_char *
-nxt_cpystrn(u_char *dst, const u_char *src, size_t len)
+nxt_cpystrn(u_char *dst, const u_char *src, size_t length)
{
- if (len == 0) {
+ if (length == 0) {
return dst;
}
- while (--len != 0) {
+ while (--length != 0) {
*dst = *src;
if (*dst == '\0') {
@@ -148,12 +148,12 @@ nxt_strcasecmp(const u_char *s1, const u_char *s2)
nxt_int_t
-nxt_strncasecmp(const u_char *s1, const u_char *s2, size_t len)
+nxt_strncasecmp(const u_char *s1, const u_char *s2, size_t length)
{
u_char c1, c2;
nxt_int_t n;
- while (len-- != 0) {
+ while (length-- != 0) {
c1 = *s1++;
c2 = *s2++;
@@ -176,12 +176,12 @@ nxt_strncasecmp(const u_char *s1, const u_char *s2, size_t len)
nxt_int_t
-nxt_memcasecmp(const u_char *s1, const u_char *s2, size_t len)
+nxt_memcasecmp(const u_char *s1, const u_char *s2, size_t length)
{
u_char c1, c2;
nxt_int_t n;
- while (len-- != 0) {
+ while (length-- != 0) {
c1 = *s1++;
c2 = *s2++;
@@ -201,29 +201,29 @@ nxt_memcasecmp(const u_char *s1, const u_char *s2, size_t len)
/*
* nxt_memstrn() is intended for search of static substring "ss"
- * with known length "len" in string "s" limited by parameter "end".
+ * with known length "length" in string "s" limited by parameter "end".
* Zeros are ignored in both strings.
*/
u_char *
-nxt_memstrn(const u_char *s, const u_char *end, const char *ss, size_t len)
+nxt_memstrn(const u_char *s, const u_char *end, const char *ss, size_t length)
{
u_char c1, c2, *s2;
s2 = (u_char *) ss;
c2 = *s2++;
- len--;
+ length--;
while (s < end) {
c1 = *s++;
if (c1 == c2) {
- if (s + len > end) {
+ if (s + length > end) {
return NULL;
}
- if (nxt_memcmp(s, s2, len) == 0) {
+ if (nxt_memcmp(s, s2, length) == 0) {
return (u_char *) s - 1;
}
}
@@ -235,19 +235,20 @@ nxt_memstrn(const u_char *s, const u_char *end, const char *ss, size_t len)
/*
* nxt_strcasestrn() is intended for caseless search of static substring
- * "ss" with known length "len" in string "s" limited by parameter "end".
+ * "ss" with known length "length" in string "s" limited by parameter "end".
* Zeros are ignored in both strings.
*/
u_char *
-nxt_memcasestrn(const u_char *s, const u_char *end, const char *ss, size_t len)
+nxt_memcasestrn(const u_char *s, const u_char *end, const char *ss,
+ size_t length)
{
u_char c1, c2, *s2;
s2 = (u_char *) ss;
c2 = *s2++;
c2 = nxt_lowcase(c2);
- len--;
+ length--;
while (s < end) {
c1 = *s++;
@@ -255,11 +256,11 @@ nxt_memcasestrn(const u_char *s, const u_char *end, const char *ss, size_t len)
if (c1 == c2) {
- if (s + len > end) {
+ if (s + length > end) {
return NULL;
}
- if (nxt_memcasecmp(s, s2, len) == 0) {
+ if (nxt_memcasecmp(s, s2, length) == 0) {
return (u_char *) s - 1;
}
}
@@ -271,26 +272,26 @@ nxt_memcasestrn(const u_char *s, const u_char *end, const char *ss, size_t len)
/*
* nxt_rstrstrn() is intended to search for static substring "ss"
- * with known length "len" in string "s" limited by parameter "end"
+ * with known length "length" in string "s" limited by parameter "end"
* in reverse order. Zeros are ignored in both strings.
*/
u_char *
-nxt_rmemstrn(const u_char *s, const u_char *end, const char *ss, size_t len)
+nxt_rmemstrn(const u_char *s, const u_char *end, const char *ss, size_t length)
{
u_char c1, c2;
const u_char *s1, *s2;
- s1 = end - len;
+ s1 = end - length;
s2 = (u_char *) ss;
c2 = *s2++;
- len--;
+ length--;
while (s < s1) {
c1 = *s1;
if (c1 == c2) {
- if (nxt_memcmp(s1 + 1, s2, len) == 0) {
+ if (nxt_memcmp(s1 + 1, s2, length) == 0) {
return (u_char *) s1;
}
}
diff --git a/src/nxt_string.h b/src/nxt_string.h
index 1938bf4b..d121b788 100644
--- a/src/nxt_string.h
+++ b/src/nxt_string.h
@@ -36,47 +36,48 @@ nxt_strlen(s) \
#define \
-nxt_memzero(buf, len) \
- (void) memset(buf, 0, len)
+nxt_memzero(buf, length) \
+ (void) memset(buf, 0, length)
#define \
-nxt_memset(buf, c, len) \
- (void) memset(buf, c, len)
+nxt_memset(buf, c, length) \
+ (void) memset(buf, c, length)
#define \
-nxt_memcpy(dst, src, len) \
- (void) memcpy(dst, src, len)
+nxt_memcpy(dst, src, length) \
+ (void) memcpy(dst, src, length)
-NXT_EXPORT void nxt_memcpy_lowcase(u_char *dst, const u_char *src, size_t len);
+NXT_EXPORT void nxt_memcpy_lowcase(u_char *dst, const u_char *src,
+ size_t length);
/*
- * nxt_cpymem() is an inline function but not macro to
- * eliminate possible double evaluation of length "len".
+ * nxt_cpymem() is an inline function but not a macro to
+ * eliminate possible double evaluation of length "length".
*/
nxt_inline void *
-nxt_cpymem(void *dst, const void *src, size_t len)
+nxt_cpymem(void *dst, const void *src, size_t length)
{
- return ((u_char *) memcpy(dst, src, len)) + len;
+ return ((u_char *) memcpy(dst, src, length)) + length;
}
#define \
-nxt_memmove(dst, src, len) \
- (void) memmove(dst, src, len)
+nxt_memmove(dst, src, length) \
+ (void) memmove(dst, src, length)
#define \
-nxt_memcmp(s1, s2, len) \
- memcmp((char *) s1, (char *) s2, len)
+nxt_memcmp(s1, s2, length) \
+ memcmp((char *) s1, (char *) s2, length)
#define \
-nxt_memchr(s, c, len) \
- memchr((char *) s, c, len)
+nxt_memchr(s, c, length) \
+ memchr((char *) s, c, length)
#define \
@@ -85,29 +86,29 @@ nxt_strcmp(s1, s2) \
#define \
-nxt_strncmp(s1, s2, len) \
- strncmp((char *) s1, (char *) s2, len)
+nxt_strncmp(s1, s2, length) \
+ strncmp((char *) s1, (char *) s2, length)
-NXT_EXPORT u_char *nxt_cpystrn(u_char *dst, const u_char *src, size_t len);
+NXT_EXPORT u_char *nxt_cpystrn(u_char *dst, const u_char *src, size_t length);
NXT_EXPORT nxt_int_t nxt_strcasecmp(const u_char *s1, const u_char *s2);
NXT_EXPORT nxt_int_t nxt_strncasecmp(const u_char *s1, const u_char *s2,
- size_t len);
+ size_t length);
NXT_EXPORT nxt_int_t nxt_memcasecmp(const u_char *s1, const u_char *s2,
- size_t len);
+ size_t length);
NXT_EXPORT u_char *nxt_memstrn(const u_char *s, const u_char *end,
- const char *ss, size_t len);
+ const char *ss, size_t length);
NXT_EXPORT u_char *nxt_memcasestrn(const u_char *s, const u_char *end,
- const char *ss, size_t len);
+ const char *ss, size_t length);
NXT_EXPORT u_char *nxt_rmemstrn(const u_char *s, const u_char *end,
- const char *ss, size_t len);
+ const char *ss, size_t length);
NXT_EXPORT size_t nxt_str_strip(u_char *start, u_char *end);
typedef struct {
- size_t len;
- u_char *data;
+ size_t length;
+ u_char *start;
} nxt_str_t;
@@ -119,20 +120,20 @@ typedef struct {
#define \
nxt_str_set(str, text) \
do { \
- (str)->len = sizeof(text) - 1; \
- (str)->data = (u_char *) text; \
+ (str)->length = sizeof(text) - 1; \
+ (str)->start = (u_char *) text; \
} while (0)
#define \
nxt_str_null(str) \
do { \
- (str)->len = 0; \
- (str)->data = NULL; \
+ (str)->length = 0; \
+ (str)->start = NULL; \
} while (0)
-NXT_EXPORT nxt_str_t *nxt_str_alloc(nxt_mem_pool_t *mp, size_t len);
+NXT_EXPORT nxt_str_t *nxt_str_alloc(nxt_mem_pool_t *mp, size_t length);
NXT_EXPORT nxt_str_t *nxt_str_dup(nxt_mem_pool_t *mp, nxt_str_t *dst,
const nxt_str_t *src);
NXT_EXPORT char *nxt_str_copy(nxt_mem_pool_t *mp, const nxt_str_t *src);
@@ -140,34 +141,34 @@ NXT_EXPORT char *nxt_str_copy(nxt_mem_pool_t *mp, const nxt_str_t *src);
#define \
nxt_strstr_eq(s1, s2) \
- (((s1)->len == (s2)->len) \
- && (nxt_memcmp((s1)->data, (s2)->data, (s1)->len) == 0))
+ (((s1)->length == (s2)->length) \
+ && (nxt_memcmp((s1)->start, (s2)->start, (s1)->length) == 0))
#define \
nxt_strcasestr_eq(s1, s2) \
- (((s1)->len == (s2)->len) \
- && (nxt_memcasecmp((s1)->data, (s2)->data, (s1)->len) == 0))
+ (((s1)->length == (s2)->length) \
+ && (nxt_memcasecmp((s1)->start, (s2)->start, (s1)->length) == 0))
#define \
-nxt_str_eq(s, p, _len) \
- (((s)->len == _len) && (nxt_memcmp((s)->data, p, _len) == 0))
+nxt_str_eq(s, p, _length) \
+ (((s)->length == _length) && (nxt_memcmp((s)->start, p, _length) == 0))
#define \
-nxt_str_start(s, p, _len) \
- (((s)->len > _len) && (nxt_memcmp((s)->data, p, _len) == 0))
+nxt_str_start(s, p, _length) \
+ (((s)->length > _length) && (nxt_memcmp((s)->start, p, _length) == 0))
#define \
nxt_strchr_eq(s, c) \
- (((s)->len == 1) && ((s)->data[0] == c))
+ (((s)->length == 1) && ((s)->start[0] == c))
#define \
nxt_strchr_start(s, c) \
- (((s)->len != 0) && ((s)->data[0] == c))
+ (((s)->length != 0) && ((s)->start[0] == c))
#endif /* _NXT_STRING_H_INCLUDED_ */
diff --git a/src/nxt_thread_time.c b/src/nxt_thread_time.c
index f359a95e..916aa564 100644
--- a/src/nxt_thread_time.c
+++ b/src/nxt_thread_time.c
@@ -102,7 +102,7 @@ nxt_thread_time_free(nxt_thread_t *thr)
thr->time.no_cache = 1;
for (i = 0; i < thr->time.nstrings; i++) {
- nxt_free(tsc[i].string.data);
+ nxt_free(tsc[i].string.start);
}
nxt_free(tsc);
@@ -353,7 +353,7 @@ nxt_thread_time_string(nxt_thread_t *thr, nxt_time_string_t *ts, u_char *buf)
}
- p = tsc->string.data;
+ p = tsc->string.start;
if (nxt_slow_path(p == NULL)) {
@@ -365,21 +365,21 @@ nxt_thread_time_string(nxt_thread_t *thr, nxt_time_string_t *ts, u_char *buf)
return buf;
}
- tsc->string.data = p;
+ tsc->string.start = p;
}
p = ts->handler(p, &thr->time.now.realtime, tm, ts->size, ts->format);
- tsc->string.len = p - tsc->string.data;
+ tsc->string.length = p - tsc->string.start;
- if (nxt_slow_path(tsc->string.len == 0)) {
+ if (nxt_slow_path(tsc->string.length == 0)) {
return buf;
}
tsc->last = s;
}
- return nxt_cpymem(buf, tsc->string.data, tsc->string.len);
+ return nxt_cpymem(buf, tsc->string.start, tsc->string.length);
}
@@ -441,7 +441,7 @@ nxt_thread_time_string_cache(nxt_thread_t *thr, nxt_atomic_uint_t slot)
if (nxt_fast_path(slot < thr->time.nstrings)) {
tsc = &thr->time.strings[slot];
- nxt_prefetch(tsc->string.data);
+ nxt_prefetch(tsc->string.start);
return tsc;
}
@@ -458,7 +458,7 @@ nxt_thread_time_string_cache(nxt_thread_t *thr, nxt_atomic_uint_t slot)
for (i = thr->time.nstrings; i < nstrings; i++) {
tsc[i].last = -1;
- tsc[i].string.data = NULL;
+ tsc[i].string.start = NULL;
}
thr->time.strings = tsc;