mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
Remove simpler cases of OOM error handling (after *alloc calls)
By simpler cases I mean cases where the OOM error is not expected to be handled by the caller of the function that calls `alloc`, `lalloc`, `xrealloc`, `xmalloc`, `alloc_clear`, and `lalloc_clear`. These are the functions that: - Do not return an allocated buffer - Have OOM as the only error condition I took note of the functions that expect the caller to handle the OOM error and will go through them to check all the callers that may be handling OOM error in future commits. I'm ignoring eval.c and ex_.c in this series of commits. eval.c will soon be obsolete and I will deal with ex_.c in later PRs.
This commit is contained in:

committed by
Thiago de Arruda

parent
6bbffee0a5
commit
13848aadbf
@@ -1143,11 +1143,6 @@ int flags; /* EW_* flags */
|
||||
}
|
||||
}
|
||||
command = alloc(len);
|
||||
if (command == NULL) {
|
||||
/* out of memory */
|
||||
vim_free(tempname);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build the shell command:
|
||||
@@ -1297,13 +1292,6 @@ int flags; /* EW_* flags */
|
||||
len = ftell(fd); /* get size of temp file */
|
||||
fseek(fd, 0L, SEEK_SET);
|
||||
buffer = alloc(len + 1);
|
||||
if (buffer == NULL) {
|
||||
/* out of memory */
|
||||
mch_remove(tempname);
|
||||
vim_free(tempname);
|
||||
fclose(fd);
|
||||
return FAIL;
|
||||
}
|
||||
i = fread((char *)buffer, 1, len, fd);
|
||||
fclose(fd);
|
||||
mch_remove(tempname);
|
||||
@@ -1388,11 +1376,6 @@ int flags; /* EW_* flags */
|
||||
}
|
||||
*num_file = i;
|
||||
*file = (char_u **)alloc(sizeof(char_u *) * i);
|
||||
if (*file == NULL) {
|
||||
/* out of memory */
|
||||
vim_free(buffer);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Isolate the individual file names.
|
||||
@@ -1437,12 +1420,10 @@ int flags; /* EW_* flags */
|
||||
continue;
|
||||
|
||||
p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
|
||||
if (p) {
|
||||
STRCPY(p, (*file)[i]);
|
||||
if (dir)
|
||||
add_pathsep(p); /* add '/' to a directory name */
|
||||
(*file)[j++] = p;
|
||||
}
|
||||
STRCPY(p, (*file)[i]);
|
||||
if (dir)
|
||||
add_pathsep(p); /* add '/' to a directory name */
|
||||
(*file)[j++] = p;
|
||||
}
|
||||
vim_free(buffer);
|
||||
*num_file = j;
|
||||
|
Reference in New Issue
Block a user