- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitcc99baa
committed
Improve pg_list.h's linitial(), lsecond() and co macros
Prior to this commit, the linitial(), lsecond(), lthird(), lfourth()macros and their int and Oid list cousins would call their correspondinginlined function to fetch the cell of interest. Those inline functionswere kind enough to return NULL if the particular cell did not exist.Unfortunately, the care that these functions took was of no relevance tothe calling macros as they proceeded to directly dereference the returnedvalue without any regard to whether that value was NULL or not. If it hadbeen, we'd have segfaulted.Of course, the fact that we would have segfaulted on misuse of thesemacros just goes to prove that nobody is relying on the empty or list toosmall checks. So here we just get rid of those checks completely.The existing inline functions have been left alone as someone may be usingthose directly. We just replace the call within each macro to uselist_nth_cell().For the llast*() case we require a new list_last_cell() inline function toget away from the multiple evaluation hazard that we'd get if we fetched->length on the macro's parameter.Author: David RowleyReviewed-by: Tom LaneDiscussion:https://postgr.es/m/CAApHDvpo1zj9KhEpU2cCRZfSM3Q6XGdhzuAS2v79PH7WJBkYVA@mail.gmail.com1 parent4d29e6d commitcc99baa
1 file changed
+25
-16
lines changedLines changed: 25 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
186 | 186 |
| |
187 | 187 |
| |
188 | 188 |
| |
189 |
| - | |
190 | 189 |
| |
191 | 190 |
| |
192 | 191 |
| |
193 | 192 |
| |
194 | 193 |
| |
195 |
| - | |
196 |
| - | |
197 |
| - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
198 | 197 |
| |
199 | 198 |
| |
200 |
| - | |
201 |
| - | |
202 |
| - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
203 | 202 |
| |
204 | 203 |
| |
205 |
| - | |
206 |
| - | |
207 |
| - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
208 | 207 |
| |
209 | 208 |
| |
210 |
| - | |
211 |
| - | |
212 |
| - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
213 | 212 |
| |
214 | 213 |
| |
215 |
| - | |
216 |
| - | |
217 |
| - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
218 | 217 |
| |
219 | 218 |
| |
220 | 219 |
| |
| |||
269 | 268 |
| |
270 | 269 |
| |
271 | 270 |
| |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
272 | 281 |
| |
273 | 282 |
| |
274 | 283 |
| |
|
0 commit comments
Comments
(0)