Skip to content

Commit 756ef11

Browse files
committed
patch 8.0.1680: memory allocated by libvterm is not profiled
Problem: Memory allocated by libvterm does not show up in profile. Solution: Pass allocater functions to vterm_new().
1 parent 672afb9 commit 756ef11

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/terminal.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@
3939
*
4040
* TODO:
4141
* - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in
42-
* the GUI.
42+
* the GUI. #2747
4343
* - Win32: Make terminal used for :!cmd in the GUI work better. Allow for
4444
* redirection. Probably in call to channel_set_pipes().
4545
* - implement term_setsize()
4646
* - Copy text in the vterm to the Vim buffer once in a while, so that
4747
* completion works.
48-
* - Adding WinBar to terminal window doesn't display, text isn't shifted down.
49-
* a job that uses 16 colors while Vim is using > 256.
5048
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
5149
* Higashi, 2017 Sep 19)
5250
* - after resizing windows overlap. (Boris Staletic, #2164)
@@ -3329,6 +3327,26 @@ static VTermParserCallbacks parser_fallbacks = {
33293327
NULL /* resize */
33303328
};
33313329

3330+
/*
3331+
* Use Vim's allocation functions for vterm so profiling works.
3332+
*/
3333+
static void *
3334+
vterm_malloc(size_t size, void *data UNUSED)
3335+
{
3336+
return alloc_clear(size);
3337+
}
3338+
3339+
static void
3340+
vterm_memfree(void *ptr, void *data UNUSED)
3341+
{
3342+
vim_free(ptr);
3343+
}
3344+
3345+
static VTermAllocatorFunctions vterm_allocator = {
3346+
&vterm_malloc,
3347+
&vterm_memfree
3348+
};
3349+
33323350
/*
33333351
* Create a new vterm and initialize it.
33343352
*/
@@ -3340,7 +3358,7 @@ create_vterm(term_T *term, int rows, int cols)
33403358
VTermState *state;
33413359
VTermValue value;
33423360

3343-
vterm = vterm_new(rows, cols);
3361+
vterm = vterm_new_with_allocator(rows, cols, &vterm_allocator, NULL);
33443362
term->tl_vterm = vterm;
33453363
screen = vterm_obtain_screen(vterm);
33463364
vterm_screen_set_callbacks(screen, &screen_callbacks, term);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1680,
765767
/**/
766768
1679,
767769
/**/

0 commit comments

Comments
 (0)