diff options
author | Said Al Attrach <alattrach.said@yahoo.com> | 2019-03-10 20:50:56 +0100 |
---|---|---|
committer | Said Al Attrach <alattrach.said@yahoo.com> | 2019-03-10 20:50:56 +0100 |
commit | 6db1757b53d562c0bdae43028aca5ec955c39acc (patch) | |
tree | 3739dcf5834afe0c289518e09943b737f1bec0b0 /src | |
parent | 7a6d85a778625ba83954a9e73e53e22ea9d53b4d (diff) | |
download | rneovim-6db1757b53d562c0bdae43028aca5ec955c39acc.tar.gz rneovim-6db1757b53d562c0bdae43028aca5ec955c39acc.tar.bz2 rneovim-6db1757b53d562c0bdae43028aca5ec955c39acc.zip |
fs: remove unecessary copybuf and os_open call
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/fileio.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 1e89baa8ce..7a77e7df24 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2761,19 +2761,12 @@ buf_write ( else backup_ext = p_bex; - if (backup_copy && (fd = os_open((char *)fname, O_RDONLY, 0)) >= 0) { - char_u *copybuf, *wp; + if (backup_copy) { + char_u *wp; int some_error = FALSE; char_u *dirp; char_u *rootname; - copybuf = verbose_try_malloc(BUFSIZE + 1); - if (copybuf == NULL) { - // out of memory - some_error = TRUE; - goto nobackup; - } - /* * Try to make the backup in each directory in the 'bdir' option. * @@ -2791,8 +2784,8 @@ buf_write ( /* * Isolate one directory name, using an entry in 'bdir'. */ - (void)copy_option_part(&dirp, copybuf, BUFSIZE, ","); - rootname = get_file_in_dir(fname, copybuf); + (void)copy_option_part(&dirp, IObuff, IOSIZE, ","); + rootname = get_file_in_dir(fname, IObuff); if (rootname == NULL) { some_error = TRUE; /* out of memory */ goto nobackup; @@ -2874,10 +2867,8 @@ buf_write ( break; } } -nobackup: - os_close(fd); // Ignore errors for closing read file. - xfree(copybuf); +nobackup: if (backup == NULL && errmsg == NULL) { SET_ERRMSG(_( "E509: Cannot create backup file (add ! to override)")); |