diff options
author | Shelley Vohr <shelley.vohr@gmail.com> | 2018-06-20 10:01:57 -0700 |
---|---|---|
committer | Santiago Gimeno <santiago.gimeno@gmail.com> | 2018-07-06 19:35:21 +0200 |
commit | 5124b27d355a868a07c51ca694c45b32b10f89b5 (patch) | |
tree | ffcd0664ea156ad315b775f6f60ab2a35e4a9efb /docs/src | |
parent | b16d10a0177c32d6a9442d0758031cac8a5db36e (diff) | |
download | libuv-5124b27d355a868a07c51ca694c45b32b10f89b5.tar.gz libuv-5124b27d355a868a07c51ca694c45b32b10f89b5.zip |
src: add new error apis to prevent memory leaks
This PR creates two new externally-facing APIs, uv_err_name_r() and
uv_strerror_r().
In keeping with the precedent set by POSIX, the *_r() suffix of these
two new methods indicate that the caller does the memory management and
passes in the memory that the output will be stored in, which provides
an alternative for the two existent methods (uv_err_name() and
uv_strerror()), which, when called with an unknown error code, leak a
few bytes of memory.
PR-URL: https://github.com/libuv/libuv/pull/1898
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno santiago.gimeno@gmail.com
Diffstat (limited to 'docs/src')
-rw-r--r-- | docs/src/errors.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/src/errors.rst b/docs/src/errors.rst index 7c3f95d7..b8f971f5 100644 --- a/docs/src/errors.rst +++ b/docs/src/errors.rst @@ -335,11 +335,25 @@ API Returns the error message for the given error code. Leaks a few bytes of memory when you call it with an unknown error code. +.. c:function:: char* uv_strerror_r(int err, char* buf, size_t buflen) + + Returns the error message for the given error code. The zero-terminated + message is stored in the user-supplied buffer `buf` of at most `buflen` bytes. + + .. versionadded:: 1.22.0 + .. c:function:: const char* uv_err_name(int err) Returns the error name for the given error code. Leaks a few bytes of memory when you call it with an unknown error code. +.. c:function:: char* uv_err_name_r(int err, char* buf, size_t buflen) + + Returns the error name for the given error code. The zero-terminated + name is stored in the user-supplied buffer `buf` of at most `buflen` bytes. + + .. versionadded:: 1.22.0 + .. c:function:: int uv_translate_sys_error(int sys_errno) Returns the libuv error code equivalent to the given platform dependent error |