comparison src/list.c @ 31201:b1c66bff0a66 v9.0.0934

patch 9.0.0934: various code formatting issues Commit: https://github.com/vim/vim/commit/24fe33a83a5130a5369f06d88000a3a0590a59ec Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 24 00:09:02 2022 +0000 patch 9.0.0934: various code formatting issues Problem: Various code formatting issues. Solution: Improve code formatting.
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Nov 2022 01:15:04 +0100
parents b3de17181c19
children 238ca27dbfd2
comparison
equal deleted inserted replaced
31200:a7801222c9c5 31201:b1c66bff0a66
107 return (list_alloc()); 107 return (list_alloc());
108 } 108 }
109 109
110 /* 110 /*
111 * Allocate space for a list, plus "count" items. 111 * Allocate space for a list, plus "count" items.
112 * This uses one allocation for efficiency.
113 * The reference count is not set.
112 * Next list_set_item() must be called for each item. 114 * Next list_set_item() must be called for each item.
113 */ 115 */
114 list_T * 116 list_T *
115 list_alloc_with_items(int count) 117 list_alloc_with_items(int count)
116 { 118 {
117 list_T *l; 119 list_T *l;
118 120
119 l = (list_T *)alloc_clear(sizeof(list_T) + count * sizeof(listitem_T)); 121 l = (list_T *)alloc_clear(sizeof(list_T) + count * sizeof(listitem_T));
120 if (l != NULL) 122 if (l == NULL)
121 { 123 return NULL;
122 list_init(l); 124
123 125 list_init(l);
124 if (count > 0) 126
125 { 127 if (count > 0)
126 listitem_T *li = (listitem_T *)(l + 1); 128 {
127 int i; 129 listitem_T *li = (listitem_T *)(l + 1);
128 130 int i;
129 l->lv_len = count; 131
130 l->lv_with_items = count; 132 l->lv_len = count;
131 l->lv_first = li; 133 l->lv_with_items = count;
132 l->lv_u.mat.lv_last = li + count - 1; 134 l->lv_first = li;
133 for (i = 0; i < count; ++i) 135 l->lv_u.mat.lv_last = li + count - 1;
134 { 136 for (i = 0; i < count; ++i)
135 if (i == 0) 137 {
136 li->li_prev = NULL; 138 if (i == 0)
137 else 139 li->li_prev = NULL;
138 li->li_prev = li - 1; 140 else
139 if (i == count - 1) 141 li->li_prev = li - 1;
140 li->li_next = NULL; 142 if (i == count - 1)
141 else 143 li->li_next = NULL;
142 li->li_next = li + 1; 144 else
143 ++li; 145 li->li_next = li + 1;
144 } 146 ++li;
145 } 147 }
146 } 148 }
149
147 return l; 150 return l;
148 } 151 }
149 152
150 /* 153 /*
151 * Set item "idx" for a list previously allocated with list_alloc_with_items(). 154 * Set item "idx" for a list previously allocated with list_alloc_with_items().