File tree 1 file changed +35
-0
lines changed 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,41 @@ static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list,
310
310
return node ? sys_dlist_peek_next_no_check (list , node ) : NULL ;
311
311
}
312
312
313
+ /**
314
+ * @brief get a reference to the previous item in the list, node is not NULL
315
+ *
316
+ * Faster than sys_dlist_peek_prev() if node is known not to be NULL.
317
+ *
318
+ * @param list the doubly-linked list to operate on
319
+ * @param node the node from which to get the previous element in the list
320
+ *
321
+ * @return a pointer to the previous element from a node, NULL if node is the
322
+ * tail
323
+ */
324
+
325
+ static inline sys_dnode_t * sys_dlist_peek_prev_no_check (sys_dlist_t * list ,
326
+ sys_dnode_t * node )
327
+ {
328
+ return (node == list -> head ) ? NULL : node -> prev ;
329
+ }
330
+
331
+ /**
332
+ * @brief get a reference to the previous item in the list
333
+ *
334
+ * @param list the doubly-linked list to operate on
335
+ * @param node the node from which to get the previous element in the list
336
+ *
337
+ * @return a pointer to the previous element from a node, NULL if node is the
338
+ * tail or NULL (when node comes from reading the head of an empty
339
+ * list).
340
+ */
341
+
342
+ static inline sys_dnode_t * sys_dlist_peek_prev (sys_dlist_t * list ,
343
+ sys_dnode_t * node )
344
+ {
345
+ return node ? sys_dlist_peek_prev_no_check (list , node ) : NULL ;
346
+ }
347
+
313
348
/**
314
349
* @brief get a reference to the tail item in the list
315
350
*
You can’t perform that action at this time.
0 commit comments