diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-26 13:09:42 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-26 13:09:42 -0300 |
commit | fc7bc0412ee111cdea61c89f3ec2461601013fa2 (patch) | |
tree | a7efb9c21c1903b5e79e18186d0172afb06eb40e /src/nvim/memory.h | |
parent | 3a68a4861adcc950cdbde709d4841f8ea0c52b12 (diff) | |
parent | 014febef22a279b9a457aa2830caeec1d9917461 (diff) | |
download | rneovim-fc7bc0412ee111cdea61c89f3ec2461601013fa2.tar.gz rneovim-fc7bc0412ee111cdea61c89f3ec2461601013fa2.tar.bz2 rneovim-fc7bc0412ee111cdea61c89f3ec2461601013fa2.zip |
Merge pull request #761 'fix a few strncpy calls by using xstrlcpy'
Diffstat (limited to 'src/nvim/memory.h')
-rw-r--r-- | src/nvim/memory.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/memory.h b/src/nvim/memory.h index 2723a7ba80..accf293176 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -125,6 +125,19 @@ char *xstpcpy(char *restrict dst, const char *restrict src); /// @param maxlen char *xstpncpy(char *restrict dst, const char *restrict src, size_t maxlen); +/// xstrlcpy - Copy a %NUL terminated string into a sized buffer +/// +/// Compatible with *BSD strlcpy: the result is always a valid +/// NUL-terminated string that fits in the buffer (unless, +/// of course, the buffer size is zero). It does not pad +/// out the result like strncpy() does. +/// +/// @param dst Where to copy the string to +/// @param src Where to copy the string from +/// @param size Size of destination buffer +/// @return Length of the source string (i.e.: strlen(src)) +size_t xstrlcpy(char *restrict dst, const char *restrict src, size_t size); + /// Duplicates a chunk of memory using xmalloc /// /// @see {xmalloc} |