To: vim_dev@googlegroups.com Subject: Patch 7.4.1868 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1868 Problem: Setting really_exiting causes memory leaks to be reported. Solution: Add the in_free_all_mem flag. Files: src/globals.h, src/misc2.c, src/eval.c *** ../vim-7.4.1867/src/globals.h 2016-04-29 22:58:25.618876680 +0200 --- src/globals.h 2016-06-01 23:03:33.033425661 +0200 *************** *** 635,640 **** --- 635,644 ---- EXTERN int really_exiting INIT(= FALSE); /* TRUE when we are sure to exit, e.g., after * a deadly signal */ + #if defined(EXITFREE) + EXTERN int entered_free_all_mem INIT(= FALSE); + /* TRUE when in or after free_all_mem() */ + #endif /* volatile because it is used in signal handler deathtrap(). */ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output *** ../vim-7.4.1867/src/misc2.c 2016-06-01 22:21:02.169460750 +0200 --- src/misc2.c 2016-06-01 23:03:43.101425523 +0200 *************** *** 1036,1051 **** free_all_mem(void) { buf_T *buf, *nextbuf; - static int entered = FALSE; /* When we cause a crash here it is caught and Vim tries to exit cleanly. * Don't try freeing everything again. */ ! if (entered) return; ! entered = TRUE; ! ! /* Set this flag to indicate some errors can be ignored. */ ! really_exiting = TRUE; # ifdef FEAT_AUTOCMD /* Don't want to trigger autocommands from here on. */ --- 1036,1047 ---- free_all_mem(void) { buf_T *buf, *nextbuf; /* When we cause a crash here it is caught and Vim tries to exit cleanly. * Don't try freeing everything again. */ ! if (entered_free_all_mem) return; ! entered_free_all_mem = TRUE; # ifdef FEAT_AUTOCMD /* Don't want to trigger autocommands from here on. */ *** ../vim-7.4.1867/src/eval.c 2016-06-01 22:34:44.809449434 +0200 --- src/eval.c 2016-06-01 23:04:06.617425199 +0200 *************** *** 25350,25357 **** fp = find_func(name); if (fp == NULL) { ! /* Ignore when invoked through free_all_mem(). */ ! if (!really_exiting) EMSG2(_(e_intern2), "func_unref()"); } else if (--fp->uf_refcount <= 0) --- 25350,25358 ---- fp = find_func(name); if (fp == NULL) { ! #ifdef EXITFREE ! if (!entered_free_all_mem) ! #endif EMSG2(_(e_intern2), "func_unref()"); } else if (--fp->uf_refcount <= 0) *** ../vim-7.4.1867/src/version.c 2016-06-01 22:34:44.809449434 +0200 --- src/version.c 2016-06-01 23:07:43.797422212 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 1868, /**/ -- hundred-and-one symptoms of being an internet addict: 32. You don't know what sex three of your closest friends are, because they have neutral nicknames and you never bothered to ask. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///