From b63d2626ed9e3e38a485b9990a8e65ba59d6906a Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Thu, 8 May 2014 21:32:40 -0300 Subject: Implement vim_str(n)save using xstrdup and strncpy/xmalloc --- src/nvim/strings.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/nvim/strings.c') diff --git a/src/nvim/strings.c b/src/nvim/strings.c index fbad71e3c6..731afa4452 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -46,14 +46,7 @@ */ char_u *vim_strsave(char_u *string) { - char_u *p; - unsigned len; - - len = (unsigned)STRLEN(string) + 1; - p = alloc(len); - if (p != NULL) - memmove(p, string, (size_t)len); - return p; + return (char_u *)xstrdup((char *)string); } /* @@ -64,12 +57,7 @@ char_u *vim_strsave(char_u *string) */ char_u *vim_strnsave(char_u *string, int len) { - char_u *p; - - p = alloc((unsigned)(len + 1)); - STRNCPY(p, string, len); - p[len] = NUL; - return p; + return (char_u *)strncpy(xmallocz(len), (char *)string, len); } /* -- cgit