Mercurial > vim
comparison src/list.c @ 9626:172131507c85 v7.4.2090
commit https://github.com/vim/vim/commit/df48fb456fb6bf63d94cad9b302ff01d8ee8d311
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 22 21:50:18 2016 +0200
patch 7.4.2090
Problem: Using submatch() in a lambda passed to substitute() is verbose.
Solution: Use a static list and pass it as an optional argument to the
function. Fix memory leak.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 22 Jul 2016 22:00:07 +0200 |
parents | 5eaa708ab50d |
children | 4aead6a9b7a9 |
comparison
equal
deleted
inserted
replaced
9625:4c2524dd2403 | 9626:172131507c85 |
---|---|
922 } | 922 } |
923 } | 923 } |
924 return ret; | 924 return ret; |
925 } | 925 } |
926 | 926 |
927 /* | |
928 * Initialize a static list with 10 items. | |
929 */ | |
930 void | |
931 init_static_list(staticList10_T *sl) | |
932 { | |
933 list_T *l = &sl->sl_list; | |
934 int i; | |
935 | |
936 memset(sl, 0, sizeof(staticList10_T)); | |
937 l->lv_first = &sl->sl_items[0]; | |
938 l->lv_last = &sl->sl_items[9]; | |
939 l->lv_refcount = DO_NOT_FREE_CNT; | |
940 l->lv_lock = VAR_FIXED; | |
941 sl->sl_list.lv_len = 10; | |
942 | |
943 for (i = 0; i < 10; ++i) | |
944 { | |
945 listitem_T *li = &sl->sl_items[i]; | |
946 | |
947 if (i == 0) | |
948 li->li_prev = NULL; | |
949 else | |
950 li->li_prev = li - 1; | |
951 if (i == 9) | |
952 li->li_next = NULL; | |
953 else | |
954 li->li_next = li + 1; | |
955 } | |
956 } | |
957 | |
927 #endif /* defined(FEAT_EVAL) */ | 958 #endif /* defined(FEAT_EVAL) */ |