summaryrefslogtreecommitdiff
path: root/osi
diff options
context:
space:
mode:
authorJakub Pawlowski <jpawlowski@google.com>2016-02-05 15:48:29 -0800
committerAndre Eisenbach <eisenbach@google.com>2016-02-18 10:36:08 -0800
commit0a03a42c20ebe33ce00a55154ac0931a9b010544 (patch)
tree826fd8b8ab1c1285a5832725bea5d61e2495edaf /osi
parent7adaa5a3f33476bf3442ef948b037ea93136ff04 (diff)
downloadandroid-system-bt-0a03a42c20ebe33ce00a55154ac0931a9b010544.tar.gz
android-system-bt-0a03a42c20ebe33ce00a55154ac0931a9b010544.tar.xz
Add list_back_node method to osi list
Change-Id: I919ce97373701cbdea03b8228b3a90263d7ef180
Diffstat (limited to 'osi')
-rw-r--r--osi/include/list.h4
-rw-r--r--osi/src/list.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/osi/include/list.h b/osi/include/list.h
index 54daf99..a510178 100644
--- a/osi/include/list.h
+++ b/osi/include/list.h
@@ -48,6 +48,10 @@ void *list_front(const list_t *list);
// be NULL or empty.
void *list_back(const list_t *list);
+// Returns the last node in the list without removing it. |list| may not
+// be NULL or empty.
+list_node_t *list_back_node(const list_t *list);
+
// Inserts |data| after |prev_node| in |list|. |data|, |list|, and |prev_node|
// may not be NULL. This function does not make a copy of |data| so the pointer
// must remain valid at least until the element is removed from the list or the
diff --git a/osi/src/list.c b/osi/src/list.c
index 79eb76f..9468579 100644
--- a/osi/src/list.c
+++ b/osi/src/list.c
@@ -79,6 +79,13 @@ void *list_back(const list_t *list) {
return list->tail->data;
}
+list_node_t *list_back_node(const list_t *list) {
+ assert(list != NULL);
+ assert(!list_is_empty(list));
+
+ return list->tail;
+}
+
bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) {
assert(list != NULL);
assert(prev_node != NULL);