Signs are not freed when exiting Vim as one would expect when
building with -DEXITFREE. Attached patch fixes it. This is a
minor problem. It's not a real memory leak. Fixing it only helps
to avoid seeing spurious leaks when searching for memory leaks.
-- Dominique
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: misc2.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/misc2.c,v
retrieving revision 1.78
diff -c -r1.78 misc2.c
*** misc2.c 22 Jan 2009 20:32:04 -0000 1.78
--- misc2.c 22 Feb 2009 09:42:02 -0000
***************
*** 1034,1039 ****
--- 1034,1042 ----
free_regexp_stuff();
free_tag_stuff();
free_cd_dir();
+ # ifdef FEAT_SIGNS
+ free_signs();
+ # endif
# ifdef FEAT_EVAL
set_expr_line(NULL);
# endif
Index: ex_cmds.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_cmds.c,v
retrieving revision 1.120
diff -c -r1.120 ex_cmds.c
*** ex_cmds.c 11 Feb 2009 15:03:45 -0000 1.120
--- ex_cmds.c 22 Feb 2009 09:42:05 -0000
***************
*** 6541,6546 ****
--- 6541,6547 ----
static int last_sign_typenr = MAX_TYPENR; /* is decremented */
static void sign_list_defined __ARGS((sign_T *sp));
+ static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
/*
* ":sign" command
***************
*** 6751,6771 ****
else
{
/* ":sign undefine {name}" */
! vim_free(sp->sn_name);
! vim_free(sp->sn_icon);
! #ifdef FEAT_SIGN_ICONS
! if (sp->sn_image != NULL)
! {
! out_flush();
! gui_mch_destroy_sign(sp->sn_image);
! }
! #endif
! vim_free(sp->sn_text);
! if (sp_prev == NULL)
! first_sign = sp->sn_next;
! else
! sp_prev->sn_next = sp->sn_next;
! vim_free(sp);
}
}
}
--- 6752,6758 ----
else
{
/* ":sign undefine {name}" */
! sign_undefine(sp, sp_prev);
}
}
}
***************
*** 7015,7020 ****
--- 7002,7032 ----
}
/*
+ * Undefine a sign and free its memory.
+ */
+ static void
+ sign_undefine(sp, sp_prev)
+ sign_T *sp;
+ sign_T *sp_prev;
+ {
+ vim_free(sp->sn_name);
+ vim_free(sp->sn_icon);
+ #ifdef FEAT_SIGN_ICONS
+ if (sp->sn_image != NULL)
+ {
+ out_flush();
+ gui_mch_destroy_sign(sp->sn_image);
+ }
+ #endif
+ vim_free(sp->sn_text);
+ if (sp_prev == NULL)
+ first_sign = sp->sn_next;
+ else
+ sp_prev->sn_next = sp->sn_next;
+ vim_free(sp);
+ }
+
+ /*
* Get highlighting attribute for sign "typenr".
* If "line" is TRUE: line highl, if FALSE: text highl.
*/
***************
*** 7088,7093 ****
--- 7100,7117 ----
return (char_u *)_("[Deleted]");
}
+ #if defined(EXITFREE) || defined(PROTO)
+ /*
+ * Undefine/free all signs.
+ */
+ void
+ free_signs()
+ {
+ while (first_sign != NULL)
+ sign_undefine(first_sign, NULL);
+ }
+ #endif
+
#endif
#if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO)
Index: proto/ex_cmds.pro
===================================================================
RCS file: /cvsroot/vim/vim7/src/proto/ex_cmds.pro,v
retrieving revision 1.14
diff -c -r1.14 ex_cmds.pro
*** proto/ex_cmds.pro 15 Nov 2008 13:11:52 -0000 1.14
--- proto/ex_cmds.pro 22 Feb 2009 09:42:05 -0000
***************
*** 40,45 ****
--- 40,46 ----
int read_viminfo_sub_string __ARGS((vir_T *virp, int force));
void write_viminfo_sub_string __ARGS((FILE *fp));
void free_old_sub __ARGS((void));
+ void free_signs __ARGS((void));
int prepare_tagpreview __ARGS((int undo_sync));
void ex_help __ARGS((exarg_T *eap));
char_u *check_help_lang __ARGS((char_u *arg));