aboutsummaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-04-19 02:12:47 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-24 10:31:31 -0300
commit42f1bd9b2228aaca4fb8a5597a3b5774f7ef6876 (patch)
tree8c056bd42ec55f2103d65af680a54bd55dc71d7f /src/path.c
parent4b6b9117b3e8b9b624c354a703f01f0980c60946 (diff)
downloadrneovim-42f1bd9b2228aaca4fb8a5597a3b5774f7ef6876.tar.gz
rneovim-42f1bd9b2228aaca4fb8a5597a3b5774f7ef6876.tar.bz2
rneovim-42f1bd9b2228aaca4fb8a5597a3b5774f7ef6876.zip
No OOM error condition in ga_concat_strings(), concat_fnames(), concat_str()
- xmallocz() is not static anymore. There are many use cases for this function in the codebase and we should start using it. - Simpler types in ga_concat_strings()
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/path.c b/src/path.c
index d2b52ee93e..4914c681da 100644
--- a/src/path.c
+++ b/src/path.c
@@ -272,32 +272,26 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
*/
char_u *concat_fnames(char_u *fname1, char_u *fname2, int sep)
{
- char_u *dest;
-
- dest = alloc((unsigned)(STRLEN(fname1) + STRLEN(fname2) + 3));
- if (dest != NULL) {
- STRCPY(dest, fname1);
- if (sep)
- add_pathsep(dest);
- STRCAT(dest, fname2);
+ char_u *dest = xmalloc(STRLEN(fname1) + STRLEN(fname2) + 3);
+
+ STRCPY(dest, fname1);
+ if (sep) {
+ add_pathsep(dest);
}
+ STRCAT(dest, fname2);
+
return dest;
}
/*
* Concatenate two strings and return the result in allocated memory.
- * Returns NULL when out of memory.
*/
char_u *concat_str(char_u *str1, char_u *str2)
{
- char_u *dest;
size_t l = STRLEN(str1);
-
- dest = alloc((unsigned)(l + STRLEN(str2) + 1L));
- if (dest != NULL) {
- STRCPY(dest, str1);
- STRCPY(dest + l, str2);
- }
+ char_u *dest = xmalloc(l + STRLEN(str2) + 1);
+ STRCPY(dest, str1);
+ STRCPY(dest + l, str2);
return dest;
}
@@ -916,8 +910,6 @@ expand_in_path (
paths = ga_concat_strings(&path_ga);
ga_clear_strings(&path_ga);
- if (paths == NULL)
- return 0;
files = globpath(paths, pattern, (flags & EW_ICASE) ? WILD_ICASE : 0);
vim_free(paths);