[WIP] add extra string handling functions

This is WIP, I'm just putting this in a PR so other people can look and give suggestions.

ref: #859
I don't see this appearing on the web interface so I'll respond via mail:

Yep, right again. How do you feel about an assert? Passing a 0-sized buffer
is probably a programming error. It will be disabled for release builds
then.


On Thu, Jun 19, 2014 at 9:10 PM, oni-link <notifications@github.com> wrote:

> In src/nvim/memory.h:
>
> > +///     // truncation happened, deal with it
> > +///   }
> > +/// @endcode
> > +///
> > +/// @return the number of bytes copied (without the NUL terminator)
> > +///
> > +/// @see xstrlcpy
> > +static inline size_t xstrucpy(char *restrict dst,
> > +                              const char *restrict src,
> > +                              size_t bufsize,
> > +                              size_t strsize)
> > +    FUNC_ATTR_NONNULL_ALL
> > +{
> > +  size_t cpy = (strsize < bufsize) ? strsize : bufsize - 1;
> > +
> > +  if (cpy) {
>
> We need further requirements, like bufsize > 0, otherwise cpy could get
> big if strsize >= bufsize.
> Then we could always NUL terminate without the if check.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/neovim/neovim/pull/869/files#r13987329>.
>