Hi

Command custom completion (:help :command-completion-customlist)
is leaking memory when redefining completion for a command
multiple times. I see this bug in latest Vim-7.2.132.

The following script illustrates the problem: memory usage keeps
growing at each iteration when redefining a command completion:

  :function! s:Foo()
  :endfunction

  :function! s:CompleteFoo(a, l, p)
  :endfunction

  :while 1
  :  " Leak at each iteration
  :  command! -complete=customlist,s:CompleteFoo -nargs=1 Foo :call s:Foo()
  :endwhile

Attached patch fixes the memory leak.

Regards
-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Index: ex_docmd.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_docmd.c,v
retrieving revision 1.166
diff -c -r1.166 ex_docmd.c
*** ex_docmd.c	1 Mar 2009 01:45:15 -0000	1.166
--- ex_docmd.c	10 Mar 2009 19:24:08 -0000
***************
*** 5148,5153 ****
--- 5148,5157 ----
  
  	cmd->uc_name = p;
      }
+ #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
+     else
+ 	vim_free(cmd->uc_compl_arg); /* free previous compl. arg if any */
+ #endif
  
      cmd->uc_rep = rep_buf;
      cmd->uc_argt = argt;
***************
*** 5941,5947 ****
      for (;;)
      {
  	p = cmd->uc_rep;    /* source */
! 	q = buf;	    /* destinateion */
  	totlen = 0;
  
  	for (;;)
--- 5945,5951 ----
      for (;;)
      {
  	p = cmd->uc_rep;    /* source */
! 	q = buf;	    /* destination */
  	totlen = 0;
  
  	for (;;)

Raspunde prin e-mail lui