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 / 6.0.140 < prev    next >
Encoding:
Internet Message Format  |  2002-01-15  |  4.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.140
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.140
  11. Problem:    Memory allocated for local mappings and abbreviations is leaked
  12.         when the buffer is wiped out.
  13. Solution:   Clear the local mappings when deleting a buffer.
  14. Files:        src/buffer.c, src/getchar.c, src/proto/getchar.pro, src/vim.h
  15.  
  16.  
  17. *** ../vim60.139/src/buffer.c    Mon Jan 14 12:49:05 2002
  18. --- src/buffer.c    Wed Jan 16 13:05:47 2002
  19. ***************
  20. *** 507,512 ****
  21. --- 507,516 ----
  22.   #endif
  23.   #ifdef FEAT_USR_CMDS
  24.       uc_clear(&buf->b_ucmds);        /* clear local user commands */
  25. + #ifdef FEAT_LOCALMAP
  26. +     map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE);  /* clear local mappings */
  27. +     map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE);   /* clear local abbrevs */
  28. + #endif
  29.   #endif
  30.       free_buf_options(buf, TRUE);
  31.   #ifdef FEAT_MBYTE
  32. *** ../vim60.139/src/getchar.c    Tue Jan 15 14:28:35 2002
  33. --- src/getchar.c    Wed Jan 16 12:49:18 2002
  34. ***************
  35. *** 3278,3287 ****
  36.       int        forceit;
  37.       int        abbr;
  38.   {
  39. -     mapblock_T    *mp, **mpp;
  40.       int        mode;
  41. -     int        hash;
  42. -     int        new_hash;
  43.   #ifdef FEAT_LOCALMAP
  44.       int        local;
  45.   
  46. --- 3278,3284 ----
  47. ***************
  48. *** 3293,3301 ****
  49.       }
  50.   #endif
  51.   
  52. -     validate_maphash();
  53.       mode = get_map_mode(&cmdp, forceit);
  54.   
  55.       for (hash = 0; hash < 256; ++hash)
  56.       {
  57. --- 3290,3320 ----
  58.       }
  59.   #endif
  60.   
  61.       mode = get_map_mode(&cmdp, forceit);
  62. +     map_clear_int(curbuf, mode,
  63. + #ifdef FEAT_LOCALMAP
  64. +         local,
  65. + #else
  66. +         FALSE,
  67. + #endif
  68. +         abbr);
  69. + }
  70. + /*
  71. +  * Clear all mappings in "mode".
  72. +  */
  73. +     void
  74. + map_clear_int(buf, mode, local, abbr)
  75. +     buf_T    *buf;        /* buffer for local mappings */
  76. +     int        mode;        /* mode in which to delete */
  77. +     int        local;        /* TRUE for buffer-local mappings */
  78. +     int        abbr;        /* TRUE for abbreviations */
  79. + {
  80. +     mapblock_T    *mp, **mpp;
  81. +     int        hash;
  82. +     int        new_hash;
  83. +     validate_maphash();
  84.   
  85.       for (hash = 0; hash < 256; ++hash)
  86.       {
  87. ***************
  88. *** 3305,3311 ****
  89.           break;
  90.   #ifdef FEAT_LOCALMAP
  91.           if (local)
  92. !         mpp = &curbuf->b_first_abbr;
  93.           else
  94.   #endif
  95.           mpp = &first_abbr;
  96. --- 3324,3330 ----
  97.           break;
  98.   #ifdef FEAT_LOCALMAP
  99.           if (local)
  100. !         mpp = &buf->b_first_abbr;
  101.           else
  102.   #endif
  103.           mpp = &first_abbr;
  104. ***************
  105. *** 3314,3320 ****
  106.       {
  107.   #ifdef FEAT_LOCALMAP
  108.           if (local)
  109. !         mpp = &curbuf->b_maphash[hash];
  110.           else
  111.   #endif
  112.           mpp = &maphash[hash];
  113. --- 3333,3339 ----
  114.       {
  115.   #ifdef FEAT_LOCALMAP
  116.           if (local)
  117. !         mpp = &buf->b_maphash[hash];
  118.           else
  119.   #endif
  120.           mpp = &maphash[hash];
  121. ***************
  122. *** 3340,3347 ****
  123.   #ifdef FEAT_LOCALMAP
  124.               if (local)
  125.               {
  126. !             mp->m_next = curbuf->b_maphash[new_hash];
  127. !             curbuf->b_maphash[new_hash] = mp;
  128.               }
  129.               else
  130.   #endif
  131. --- 3359,3366 ----
  132.   #ifdef FEAT_LOCALMAP
  133.               if (local)
  134.               {
  135. !             mp->m_next = buf->b_maphash[new_hash];
  136. !             buf->b_maphash[new_hash] = mp;
  137.               }
  138.               else
  139.   #endif
  140. *** ../vim60.139/src/proto/getchar.pro    Sun Oct 28 21:23:45 2001
  141. --- src/proto/getchar.pro    Wed Jan 16 13:05:25 2002
  142. ***************
  143. *** 41,46 ****
  144. --- 41,47 ----
  145.   int do_map __ARGS((int maptype, char_u *arg, int mode, int abbrev));
  146.   int get_map_mode __ARGS((char_u **cmdp, int forceit));
  147.   void map_clear __ARGS((char_u *cmdp, char_u *arg, int forceit, int abbr));
  148. + void map_clear_int __ARGS((buf_T *buf, int mode, int local, int abbr));
  149.   int map_to_exists __ARGS((char_u *str, char_u *modechars));
  150.   int map_to_exists_mode __ARGS((char_u *rhs, int mode));
  151.   char_u *set_context_in_map_cmd __ARGS((expand_T *xp, char_u *cmd, char_u *arg, int forceit, int isabbrev, int isunmap, cmdidx_T cmdidx));
  152. *** ../vim60.139/src/vim.h    Wed Sep 19 16:57:09 2001
  153. --- src/vim.h    Wed Jan 16 13:03:57 2002
  154. ***************
  155. *** 501,506 ****
  156. --- 501,507 ----
  157.   #define INSERT        0x10    /* Insert mode */
  158.   #define LANGMAP        0x20    /* Language mapping, can be combined with
  159.                      INSERT and CMDLINE */
  160. + #define MAP_ALL_MODES    0x3f    /* all mode bits used for mapping */
  161.   
  162.   #define REPLACE_FLAG    0x40    /* Replace mode flag */
  163.   #define REPLACE        (REPLACE_FLAG + INSERT)
  164. *** ../vim60.139/src/version.c    Wed Jan 16 12:28:44 2002
  165. --- src/version.c    Wed Jan 16 13:45:27 2002
  166. ***************
  167. *** 608,609 ****
  168. --- 608,611 ----
  169.   {   /* Add new patch number below this line */
  170. + /**/
  171. +     140,
  172.   /**/
  173.  
  174. -- 
  175. hundred-and-one symptoms of being an internet addict:
  176. 6. You refuse to go to a vacation spot with no electricity and no phone lines.
  177.  
  178.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  179. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  180.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  181.