Skip to content

Commit 623e263

Browse files
committed
patch 7.4.2130
Problem: Pending timers cause false memory leak reports. Solution: Free all timers on exit.
1 parent 3ab1435 commit 623e263

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/ex_cmds2.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,21 @@ set_ref_in_timer(int copyID)
12791279
}
12801280
return abort;
12811281
}
1282+
1283+
# if defined(EXITFREE) || defined(PROTO)
1284+
void
1285+
timer_free_all()
1286+
{
1287+
timer_T *timer;
1288+
1289+
while (first_timer != NULL)
1290+
{
1291+
timer = first_timer;
1292+
remove_timer(timer);
1293+
free_timer(timer);
1294+
}
1295+
}
1296+
# endif
12821297
# endif
12831298

12841299
#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_FLOAT)

src/misc2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,9 @@ free_all_mem(void)
12241224
channel_free_all();
12251225
job_free_all();
12261226
# endif
1227+
#ifdef FEAT_TIMERS
1228+
timer_free_all();
1229+
#endif
12271230

12281231
free_termoptions();
12291232

src/proto/ex_cmds2.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ float_T profile_float(proftime_T *tm);
1818
void profile_setlimit(long msec, proftime_T *tm);
1919
int profile_passed_limit(proftime_T *tm);
2020
void profile_zero(proftime_T *tm);
21-
timer_T *create_timer(long msec, int repeats);
21+
timer_T *create_timer(long msec, int repeat);
2222
long check_due_timer(void);
2323
timer_T *find_timer(int id);
2424
void stop_timer(timer_T *timer);
2525
int set_ref_in_timer(int copyID);
26+
void timer_free_all(void);
2627
void profile_divide(proftime_T *tm, int count, proftime_T *tm2);
2728
void profile_add(proftime_T *tm, proftime_T *tm2);
2829
void profile_self(proftime_T *self, proftime_T *total, proftime_T *children);

src/version.c

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

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2130,
766768
/**/
767769
2129,
768770
/**/

0 commit comments

Comments
 (0)