home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.2 / 7.2.238 < prev    next >
Encoding:
Internet Message Format  |  2009-07-21  |  3.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.2.238
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.2.238
  11. Problem:    Leaking memory when setting term to "builtin_dumb".
  12. Solution:   Free memory when resetting term option t_Co.
  13. Files:        src/option.c, src/proto/option.pro, src/term.c
  14.  
  15.  
  16. *** ../vim-7.2.237/src/option.c    2009-06-16 17:50:56.000000000 +0200
  17. --- src/option.c    2009-07-22 12:49:19.000000000 +0200
  18. ***************
  19. *** 403,410 ****
  20.   #define P_NUM        0x02    /* the option is numeric */
  21.   #define P_STRING    0x04    /* the option is a string */
  22.   #define P_ALLOCED    0x08    /* the string option is in allocated memory,
  23. !                     must use vim_free() when assigning new
  24. !                     value. Not set if default is the same. */
  25.   #define P_EXPAND    0x10    /* environment expansion.  NOTE: P_EXPAND can
  26.                      never be used for local or hidden options! */
  27.   #define P_NODEFAULT    0x40    /* don't set to default value */
  28. --- 403,411 ----
  29.   #define P_NUM        0x02    /* the option is numeric */
  30.   #define P_STRING    0x04    /* the option is a string */
  31.   #define P_ALLOCED    0x08    /* the string option is in allocated memory,
  32. !                    must use free_string_option() when
  33. !                    assigning new value. Not set if default is
  34. !                    the same. */
  35.   #define P_EXPAND    0x10    /* environment expansion.  NOTE: P_EXPAND can
  36.                      never be used for local or hidden options! */
  37.   #define P_NODEFAULT    0x40    /* don't set to default value */
  38. ***************
  39. *** 8927,8932 ****
  40. --- 8928,8955 ----
  41.   }
  42.   
  43.   /*
  44. +  * Free the string for one term option, if it was allocated.
  45. +  * Set the string to empty_option and clear allocated flag.
  46. +  * "var" points to the option value.
  47. +  */
  48. +     void
  49. + free_one_termoption(var)
  50. +     char_u *var;
  51. + {
  52. +     struct vimoption   *p;
  53. +     for (p = &options[0]; p->fullname != NULL; p++)
  54. +     if (p->var == var)
  55. +     {
  56. +         if (p->flags & P_ALLOCED)
  57. +         free_string_option(*(char_u **)(p->var));
  58. +         *(char_u **)(p->var) = empty_option;
  59. +         p->flags &= ~P_ALLOCED;
  60. +         break;
  61. +     }
  62. + }
  63. + /*
  64.    * Set the terminal option defaults to the current value.
  65.    * Used after setting the terminal name.
  66.    */
  67. *** ../vim-7.2.237/src/proto/option.pro    2009-02-21 20:27:00.000000000 +0100
  68. --- src/proto/option.pro    2009-07-22 12:52:31.000000000 +0200
  69. ***************
  70. *** 29,34 ****
  71. --- 29,35 ----
  72.   int makefoldset __ARGS((FILE *fd));
  73.   void clear_termoptions __ARGS((void));
  74.   void free_termoptions __ARGS((void));
  75. + void free_one_termoption __ARGS((char_u *var));
  76.   void set_term_defaults __ARGS((void));
  77.   void comp_col __ARGS((void));
  78.   char_u *get_equalprg __ARGS((void));
  79. *** ../vim-7.2.237/src/term.c    2009-06-16 14:31:56.000000000 +0200
  80. --- src/term.c    2009-07-22 13:19:59.000000000 +0200
  81. ***************
  82. *** 2881,2887 ****
  83.   
  84.       /* if 'Sb' and 'AB' are not defined, reset "Co" */
  85.       if (*T_CSB == NUL && *T_CAB == NUL)
  86. !         T_CCO = empty_option;
  87.   
  88.       /* Set 'weirdinvert' according to value of 't_xs' */
  89.       p_wiv = (*T_XS != NUL);
  90. --- 2881,2887 ----
  91.   
  92.       /* if 'Sb' and 'AB' are not defined, reset "Co" */
  93.       if (*T_CSB == NUL && *T_CAB == NUL)
  94. !         free_one_termoption(T_CCO);
  95.   
  96.       /* Set 'weirdinvert' according to value of 't_xs' */
  97.       p_wiv = (*T_XS != NUL);
  98. *** ../vim-7.2.237/src/version.c    2009-07-22 13:27:50.000000000 +0200
  99. --- src/version.c    2009-07-22 14:25:44.000000000 +0200
  100. ***************
  101. *** 678,679 ****
  102. --- 678,681 ----
  103.   {   /* Add new patch number below this line */
  104. + /**/
  105. +     238,
  106.   /**/
  107.  
  108. -- 
  109. hundred-and-one symptoms of being an internet addict:
  110. 95. Only communication in your household is through email.
  111.  
  112.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  113. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  114. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  115.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  116.