Mercurial > vim
comparison src/channel.c @ 9143:b9c1a397a8a6 v7.4.1855
commit https://github.com/vim/vim/commit/655da31a18ef3f888acf10e68b438e2a851f7b14
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 28 22:22:34 2016 +0200
patch 7.4.1855
Problem: Valgrind reports memory leak for job that is not freed.
Solution: Free all jobs on exit. Add test for failing job.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 28 May 2016 22:30:06 +0200 |
parents | ddca37101ffb |
children | 053bc64433ec |
comparison
equal
deleted
inserted
replaced
9142:2afd9e149d88 | 9143:b9c1a397a8a6 |
---|---|
1283 { | 1283 { |
1284 char_u *line = ml_get_buf(buf, lnum, FALSE); | 1284 char_u *line = ml_get_buf(buf, lnum, FALSE); |
1285 int len = (int)STRLEN(line); | 1285 int len = (int)STRLEN(line); |
1286 char_u *p; | 1286 char_u *p; |
1287 | 1287 |
1288 /* Need to make a copy to be able to append a NL. */ | |
1288 if ((p = alloc(len + 2)) == NULL) | 1289 if ((p = alloc(len + 2)) == NULL) |
1289 return; | 1290 return; |
1290 STRCPY(p, line); | 1291 STRCPY(p, line); |
1291 p[len] = NL; | 1292 p[len] = NL; |
1292 p[len + 1] = NUL; | 1293 p[len + 1] = NUL; |
2886 } | 2887 } |
2887 | 2888 |
2888 /* | 2889 /* |
2889 * Read from channel "channel" for as long as there is something to read. | 2890 * Read from channel "channel" for as long as there is something to read. |
2890 * "part" is PART_SOCK, PART_OUT or PART_ERR. | 2891 * "part" is PART_SOCK, PART_OUT or PART_ERR. |
2891 * The data is put in the read queue. | 2892 * The data is put in the read queue. No callbacks are invoked here. |
2892 */ | 2893 */ |
2893 static void | 2894 static void |
2894 channel_read(channel_T *channel, int part, char *func) | 2895 channel_read(channel_T *channel, int part, char *func) |
2895 { | 2896 { |
2896 static char_u *buf = NULL; | 2897 static char_u *buf = NULL; |
4182 job_free_contents(job); | 4183 job_free_contents(job); |
4183 job_free_job(job); | 4184 job_free_job(job); |
4184 } | 4185 } |
4185 } | 4186 } |
4186 | 4187 |
4188 #if defined(EXITFREE) || defined(PROTO) | |
4189 void | |
4190 job_free_all(void) | |
4191 { | |
4192 while (first_job != NULL) | |
4193 job_free(first_job); | |
4194 } | |
4195 #endif | |
4196 | |
4187 /* | 4197 /* |
4188 * Return TRUE if the job should not be freed yet. Do not free the job when | 4198 * Return TRUE if the job should not be freed yet. Do not free the job when |
4189 * it has not ended yet and there is a "stoponexit" flag, an exit callback | 4199 * it has not ended yet and there is a "stoponexit" flag, an exit callback |
4190 * or when the associated channel will do something with the job output. | 4200 * or when the associated channel will do something with the job output. |
4191 */ | 4201 */ |