aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2021-02-06 12:56:20 +0900
committerGitHub <noreply@github.com>2021-02-06 12:56:20 +0900
commit957ac9442cd71386b374a162cf22a4f5d1618fe5 (patch)
tree18c27512982f14748ee430beb1ec83f5f3434ec7 /src
parent787339892d7d0417716945dc1088f04031cab5ad (diff)
parentcb457f5f7fab4c42b15e7f27313deeb203fcfec6 (diff)
downloadrneovim-957ac9442cd71386b374a162cf22a4f5d1618fe5.tar.gz
rneovim-957ac9442cd71386b374a162cf22a4f5d1618fe5.tar.bz2
rneovim-957ac9442cd71386b374a162cf22a4f5d1618fe5.zip
Merge pull request #13702 from erw7/fix-build_stl_str_hl
buffer.c: fix problem of memory allocation
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index ec39de14f5..7116b25b29 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3486,7 +3486,7 @@ int build_stl_str_hl(
stl_items = xmalloc(sizeof(stl_item_t) * stl_items_len);
stl_groupitems = xmalloc(sizeof(int) * stl_items_len);
stl_hltab = xmalloc(sizeof(stl_hlrec_t) * stl_items_len);
- stl_tabtab = xmalloc(sizeof(stl_hlrec_t) * stl_items_len);
+ stl_tabtab = xmalloc(sizeof(StlClickRecord) * stl_items_len);
stl_separator_locations = xmalloc(sizeof(int) * stl_items_len);
}
@@ -4482,22 +4482,15 @@ int build_stl_str_hl(
int num_separators = 0;
for (int i = 0; i < itemcnt; i++) {
if (stl_items[i].type == Separate) {
+ // Create an array of the start location for each
+ // separator mark.
+ stl_separator_locations[num_separators] = i;
num_separators++;
}
}
// If we have separated groups, then we deal with it now
if (num_separators) {
- // Create an array of the start location for each
- // separator mark.
- int index = 0;
- for (int i = 0; i < itemcnt; i++) {
- if (stl_items[i].type == Separate) {
- stl_separator_locations[index] = i;
- index++;
- }
- }
-
int standard_spaces = (maxwidth - width) / num_separators;
int final_spaces = (maxwidth - width) -
standard_spaces * (num_separators - 1);