style: rename buf to buffer and len to size for consistency

PR-URL: https://github.com/libuv/libuv/pull/159
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Andrius Bentkus 2015-01-23 13:29:36 +01:00 committed by Saúl Ibarra Corretgé
parent 1e59ab1d49
commit 2bfa2e5e22
8 changed files with 44 additions and 42 deletions

View File

@ -94,11 +94,11 @@ API
Stop the handle, the callback will no longer be called.
.. c:function:: int uv_fs_event_getpath(uv_fs_event_t* handle, char* buf, size_t* len)
.. c:function:: int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size)
Get the path being monitored by the handle. The buffer must be preallocated
by the user. Returns 0 on success or an error code < 0 in case of failure.
On success, `buf` will contain the path and `len` its length. If the buffer
On success, `buffer` will contain the path and `size` its length. If the buffer
is not big enough UV_ENOBUFS will be returned and len will be set to the
required size.

View File

@ -58,11 +58,11 @@ API
Stop the handle, the callback will no longer be called.
.. c:function:: int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buf, size_t* len)
.. c:function:: int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size)
Get the path being monitored by the handle. The buffer must be preallocated
by the user. Returns 0 on success or an error code < 0 in case of failure.
On success, `buf` will contain the path and `len` its length. If the buffer
On success, `buffer` will contain the path and `size` its length. If the buffer
is not big enough UV_ENOBUFS will be returned and len will be set to the
required size.

View File

@ -56,11 +56,11 @@ API
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
92 and 108 bytes.
.. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len)
.. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size)
Get the name of the Unix domain socket or the named pipe.
A preallocated buffer must be provided. The len parameter holds the length
A preallocated buffer must be provided. The size parameter holds the length
of the buffer and it's set to the number of bytes written to the buffer on
output. If the buffer is not big enough ``UV_ENOBUFS`` will be returned and
len will contain the required size.

View File

@ -675,8 +675,8 @@ UV_EXTERN void uv_pipe_connect(uv_connect_t* req,
const char* name,
uv_connect_cb cb);
UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle,
char* buf,
size_t* len);
char* buffer,
size_t* size);
UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle);
UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle);
@ -1261,7 +1261,9 @@ UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
const char* path,
unsigned int interval);
UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buf, size_t* len);
UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle,
char* buffer,
size_t* size);
struct uv_signal_s {
@ -1318,8 +1320,8 @@ UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle,
unsigned int flags);
UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle);
UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle,
char* buf,
size_t* len);
char* buffer,
size_t* size);
UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr);
UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr);

View File

@ -125,12 +125,12 @@ int uv_fs_poll_stop(uv_fs_poll_t* handle) {
}
int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buf, size_t* len) {
int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
struct poll_ctx* ctx;
size_t required_len;
if (!uv__is_active(handle)) {
*len = 0;
*size = 0;
return UV_EINVAL;
}
@ -138,13 +138,13 @@ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buf, size_t* len) {
assert(ctx != NULL);
required_len = strlen(ctx->path);
if (required_len > *len) {
*len = required_len;
if (required_len > *size) {
*size = required_len;
return UV_ENOBUFS;
}
memcpy(buf, ctx->path, required_len);
*len = required_len;
memcpy(buffer, ctx->path, required_len);
*size = required_len;
return 0;
}

View File

@ -206,7 +206,7 @@ out:
}
int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) {
struct sockaddr_un sa;
socklen_t addrlen;
int err;
@ -215,7 +215,7 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
memset(&sa, 0, addrlen);
err = getsockname(uv__stream_fd(handle), (struct sockaddr*) &sa, &addrlen);
if (err < 0) {
*len = 0;
*size = 0;
return -errno;
}
@ -226,13 +226,13 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
addrlen = strlen(sa.sun_path);
if (addrlen > *len) {
*len = addrlen;
if (addrlen > *size) {
*size = addrlen;
return UV_ENOBUFS;
}
memcpy(buf, sa.sun_path, addrlen);
*len = addrlen;
memcpy(buffer, sa.sun_path, addrlen);
*size = addrlen;
return 0;
}

View File

@ -359,22 +359,22 @@ int uv_send_buffer_size(uv_handle_t* handle, int *value) {
return uv__socket_sockopt(handle, SO_SNDBUF, value);
}
int uv_fs_event_getpath(uv_fs_event_t* handle, char* buf, size_t* len) {
int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size) {
size_t required_len;
if (!uv__is_active(handle)) {
*len = 0;
*size = 0;
return UV_EINVAL;
}
required_len = strlen(handle->path);
if (required_len > *len) {
*len = required_len;
if (required_len > *size) {
*size = required_len;
return UV_ENOBUFS;
}
memcpy(buf, handle->path, required_len);
*len = required_len;
memcpy(buffer, handle->path, required_len);
*size = required_len;
return 0;
}

View File

@ -1910,7 +1910,7 @@ int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
}
int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) {
NTSTATUS nt_status;
IO_STATUS_BLOCK io_status;
FILE_NAME_INFORMATION tmp_name_info;
@ -1924,7 +1924,7 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
name_info = NULL;
if (handle->handle == INVALID_HANDLE_VALUE) {
*len = 0;
*size = 0;
return UV_EINVAL;
}
@ -1939,7 +1939,7 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
name_size = sizeof(*name_info) + tmp_name_info.FileNameLength;
name_info = malloc(name_size);
if (!name_info) {
*len = 0;
*size = 0;
err = UV_ENOMEM;
goto cleanup;
}
@ -1952,7 +1952,7 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
}
if (nt_status != STATUS_SUCCESS) {
*len = 0;
*size = 0;
err = uv_translate_sys_error(pRtlNtStatusToDosError(nt_status));
goto error;
}
@ -1967,7 +1967,7 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
}
if (name_len == 0) {
*len = 0;
*size = 0;
err = 0;
goto error;
}
@ -1984,33 +1984,33 @@ int uv_pipe_getsockname(const uv_pipe_t* handle, char* buf, size_t* len) {
NULL,
NULL);
if (!addrlen) {
*len = 0;
*size = 0;
err = uv_translate_sys_error(GetLastError());
goto error;
} else if (pipe_prefix_len + addrlen > *len) {
} else if (pipe_prefix_len + addrlen > *size) {
/* "\\\\.\\pipe" + name */
*len = pipe_prefix_len + addrlen;
*size = pipe_prefix_len + addrlen;
err = UV_ENOBUFS;
goto error;
}
memcpy(buf, pipe_prefix, pipe_prefix_len);
memcpy(buffer, pipe_prefix, pipe_prefix_len);
addrlen = WideCharToMultiByte(CP_UTF8,
0,
name_buf,
name_len,
buf+pipe_prefix_len,
*len-pipe_prefix_len,
buffer+pipe_prefix_len,
*size-pipe_prefix_len,
NULL,
NULL);
if (!addrlen) {
*len = 0;
*size = 0;
err = uv_translate_sys_error(GetLastError());
goto error;
}
addrlen += pipe_prefix_len;
*len = addrlen;
*size = addrlen;
err = 0;
goto cleanup;