summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-05-17 09:24:55 -0600
committerJohn Stebbins <[email protected]>2016-05-17 09:24:55 -0600
commit94bf236dca4bf1ce41ad5c3cd719e6fe9922deb7 (patch)
treed3c47fae9025a992f34fc5d0fab67ecaad742842
parente1c6d4b143cf374ed0879f7b611899a8e8c033bc (diff)
libhb: add hb_buffer_list_rem()
-rw-r--r--libhb/common.c34
-rw-r--r--libhb/common.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 45f46b137..f282bbbcf 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -2797,6 +2797,40 @@ hb_buffer_t* hb_buffer_list_rem_tail(hb_buffer_list_t *list)
return tail;
}
+hb_buffer_t* hb_buffer_list_rem(hb_buffer_list_t *list, hb_buffer_t * b)
+{
+ hb_buffer_t * a;
+
+ if (list == NULL)
+ {
+ return NULL;
+ }
+ if (b == list->head)
+ {
+ return hb_buffer_list_rem_head(list);
+ }
+ a = list->head;
+ while (a != NULL && a->next != b)
+ {
+ a = a->next;
+ }
+ if (a == NULL)
+ {
+ // Buffer is not in the list
+ return NULL;
+ }
+ list->count--;
+ list->size -= b->size;
+ a->next = b->next;
+ if (list->tail == b)
+ {
+ list->tail = a;
+ }
+ b->next = NULL;
+
+ return b;
+}
+
hb_buffer_t* hb_buffer_list_head(hb_buffer_list_t *list)
{
if (list == NULL)
diff --git a/libhb/common.h b/libhb/common.h
index 040164ceb..834b48518 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -120,6 +120,7 @@ hb_buffer_t* hb_buffer_list_head(hb_buffer_list_t *list);
hb_buffer_t* hb_buffer_list_rem_head(hb_buffer_list_t *list);
hb_buffer_t* hb_buffer_list_tail(hb_buffer_list_t *list);
hb_buffer_t* hb_buffer_list_rem_tail(hb_buffer_list_t *list);
+hb_buffer_t* hb_buffer_list_rem(hb_buffer_list_t *list, hb_buffer_t * b);
hb_buffer_t* hb_buffer_list_clear(hb_buffer_list_t *list);
hb_buffer_t* hb_buffer_list_set(hb_buffer_list_t *list, hb_buffer_t *buf);
void hb_buffer_list_close(hb_buffer_list_t *list);