diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-01-25 17:57:01 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-01-25 17:57:01 +0000 |
commit | 9837de570c5972f98e74848edc97c297a13136ea (patch) | |
tree | cc948611912d116a3f98a744e690d3d7b6e2f59a /src/nvim/memfile.c | |
parent | c367400b73d207833d51e09d663f969ffab37531 (diff) | |
parent | 3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 (diff) | |
download | rneovim-9837de570c5972f98e74848edc97c297a13136ea.tar.gz rneovim-9837de570c5972f98e74848edc97c297a13136ea.tar.bz2 rneovim-9837de570c5972f98e74848edc97c297a13136ea.zip |
Merge remote-tracking branch 'upstream/master' into colorcolchar
Diffstat (limited to 'src/nvim/memfile.c')
-rw-r--r-- | src/nvim/memfile.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index bb9be0766e..46be9ccea5 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -43,19 +43,25 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stdio.h> #include <string.h> -#include "nvim/ascii.h" #include "nvim/assert.h" +#include "nvim/buffer_defs.h" #include "nvim/fileio.h" +#include "nvim/gettext.h" +#include "nvim/globals.h" +#include "nvim/macros.h" #include "nvim/memfile.h" +#include "nvim/memfile_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" -#include "nvim/os_unix.h" #include "nvim/path.h" +#include "nvim/pos.h" #include "nvim/vim.h" #define MEMFILE_PAGE_SIZE 4096 /// default page size @@ -752,7 +758,7 @@ void mf_free_fnames(memfile_T *mfp) void mf_set_fnames(memfile_T *mfp, char *fname) { mfp->mf_fname = fname; - mfp->mf_ffname = (char_u *)FullName_save(mfp->mf_fname, false); + mfp->mf_ffname = FullName_save(mfp->mf_fname, false); } /// Make name of memfile's swapfile a full path. @@ -760,11 +766,13 @@ void mf_set_fnames(memfile_T *mfp, char *fname) /// Used before doing a :cd void mf_fullname(memfile_T *mfp) { - if (mfp != NULL && mfp->mf_fname != NULL && mfp->mf_ffname != NULL) { - xfree(mfp->mf_fname); - mfp->mf_fname = (char *)mfp->mf_ffname; - mfp->mf_ffname = NULL; + if (mfp == NULL || mfp->mf_fname == NULL || mfp->mf_ffname == NULL) { + return; } + + xfree(mfp->mf_fname); + mfp->mf_fname = mfp->mf_ffname; + mfp->mf_ffname = NULL; } /// Return true if there are any translations pending for memfile. @@ -815,8 +823,10 @@ static bool mf_do_open(memfile_T *mfp, char *fname, int flags) /// The number of buckets in the hashtable is increased by a factor of /// MHT_GROWTH_FACTOR when the average number of items per bucket /// exceeds 2 ^ MHT_LOG_LOAD_FACTOR. -#define MHT_LOG_LOAD_FACTOR 6 -#define MHT_GROWTH_FACTOR 2 // must be a power of two +enum { + MHT_LOG_LOAD_FACTOR = 6, + MHT_GROWTH_FACTOR = 2, // must be a power of two +}; /// Initialize an empty hash table. static void mf_hash_init(mf_hashtab_T *mht) |