patch 9.1.1467: too many strlen() calls
Problem: too many strlen() calls
Solution: Change expand_env() to return string length
(John Marriott)
This commit does the following changes:
- In expand_env_esc():
- return the length of the returned dst string.
- refactor to remove some calls to STRLEN() and STRCAT()
- add check for out-of-memory condition.
- Change call sites in various source files to use the return value
closes: #17561
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
8311e7d6b4
commit
fff0132399
@ -5351,14 +5351,13 @@ vim_tempname(
|
||||
long nr;
|
||||
long off;
|
||||
# endif
|
||||
size_t itmplen;
|
||||
|
||||
// Expand $TMP, leave room for "/v1100000/999999999".
|
||||
// Skip the directory check if the expansion fails.
|
||||
expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
|
||||
itmplen = expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
|
||||
if (itmp[0] != '$' && mch_isdir(itmp))
|
||||
{
|
||||
size_t itmplen = STRLEN(itmp);
|
||||
|
||||
// directory exists
|
||||
if (!after_pathsep(itmp, itmp + itmplen))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user