UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
list.cpp File Reference
#include <list>
#include "utils/list.h"
Include dependency graph for list.cpp:

Go to the source code of this file.

Classes

struct  simple_linked_list
 
struct  sll_it
 

Functions

void simple_linked_list_append (struct simple_linked_list *l, void *data)
 
bool simple_linked_list_append_if_less (struct simple_linked_list *l, void *data, int max_size)
 
void simple_linked_list_destroy (struct simple_linked_list *l)
 
void * simple_linked_list_first (struct simple_linked_list *l)
 returns first element of list, UB if empty
 
struct simple_linked_list * simple_linked_list_init (void)
 
void simple_linked_list_it_destroy (void *i)
 Should be used when it != NULL, eg. when leaving the loop before the end.
 
void * simple_linked_list_it_init (struct simple_linked_list *l)
 
void * simple_linked_list_it_next (void **i)
 
void * simple_linked_list_it_peek_next (const void *it)
 
void * simple_linked_list_last (struct simple_linked_list *l)
 returns last element of list, UB if empty
 
void * simple_linked_list_pop (struct simple_linked_list *l)
 
void simple_linked_list_prepend (struct simple_linked_list *l, void *data)
 
bool simple_linked_list_remove (struct simple_linked_list *l, void *item)
 
void * simple_linked_list_remove_index (struct simple_linked_list *l, int index)
 
int simple_linked_list_size (struct simple_linked_list *l)
 

Detailed Description

Function Documentation

◆ simple_linked_list_append()

◆ simple_linked_list_append_if_less()

bool simple_linked_list_append_if_less ( struct simple_linked_list * l,
void * data,
int max_size )

Definition at line 73 of file list.cpp.

74{
75 if (l->l.size() >= (unsigned) max_size) {
76 return false;
77 }
78 l->l.push_back(data);
79 return true;
80}

References simple_linked_list::l.

◆ simple_linked_list_destroy()

◆ simple_linked_list_first()

void * simple_linked_list_first ( struct simple_linked_list * l)

returns first element of list, UB if empty

Definition at line 98 of file list.cpp.

99{
100 return l->l.front();
101}

References simple_linked_list::l.

Referenced by vo_postprocess(), and vo_postprocess_get_property().

◆ simple_linked_list_init()

◆ simple_linked_list_it_destroy()

void simple_linked_list_it_destroy ( void * i)

Should be used when it != NULL, eg. when leaving the loop before the end.

Definition at line 139 of file list.cpp.

140{
141 delete (sll_it *) i;
142}

Referenced by find_child(), vo_postprocess_getf(), and vo_postprocess_reconfigure().

◆ simple_linked_list_it_init()

void * simple_linked_list_it_init ( struct simple_linked_list * l)

iterator

usage: for(void *it = simple_linked_list_it_init(list); it != NULL; ) { o-type *inst = simple_linked_list_it_next(&it); process(inst); if (something_why_to_leave_the_loop) { simple_linked_list_it_destroy(it); break; } }

Definition at line 108 of file list.cpp.

109{
110 if (l->l.size() == 0) {
111 return nullptr;
112 }
113 auto ret = new sll_it();
114 ret->it = l->l.begin();
115 ret->end = l->l.end();
116 return ret;
117}

References simple_linked_list::l.

Referenced by capture_filter(), dump_tree(), find_child(), get_module_identifier(), module_check_undelivered_messages(), module_done(), vo_postprocess(), vo_postprocess_done(), vo_postprocess_getf(), and vo_postprocess_reconfigure().

◆ simple_linked_list_it_next()

void * simple_linked_list_it_next ( void ** i)

Definition at line 119 of file list.cpp.

120{
121 auto sit = (sll_it *) *i;
122
123 void *ret = *sit->it;
124 ++sit->it;
125 if (sit->it == sit->end) {
126 delete sit;
127 *i = nullptr;
128 }
129 return ret;
130}

Referenced by capture_filter(), dump_tree(), find_child(), get_module_identifier(), module_check_undelivered_messages(), module_done(), vo_postprocess(), vo_postprocess_done(), vo_postprocess_getf(), and vo_postprocess_reconfigure().

◆ simple_linked_list_it_peek_next()

void * simple_linked_list_it_peek_next ( const void * it)

return next item without actually incrementing iterator, UB if item is last (it == NULL)

Returns
item

Definition at line 132 of file list.cpp.

133{
134 const auto *sit = static_cast<const sll_it *>(it);
135
136 return *sit->it;
137}
list< void * >::iterator it
Definition list.cpp:50

References sll_it::it.

Referenced by vo_postprocess().

◆ simple_linked_list_last()

void * simple_linked_list_last ( struct simple_linked_list * l)

returns last element of list, UB if empty

Definition at line 103 of file list.cpp.

104{
105 return l->l.back();
106}

References simple_linked_list::l.

Referenced by vo_postprocess_get_out_desc(), and vo_postprocess_get_property().

◆ simple_linked_list_pop()

void * simple_linked_list_pop ( struct simple_linked_list * l)

Definition at line 82 of file list.cpp.

83{
84 if (simple_linked_list_size(l) == 0) {
85 return nullptr;
86 }
87 void *ret = l->l.front();
88 l->l.pop_front();
89
90 return ret;
91}
int simple_linked_list_size(struct simple_linked_list *l)
Definition list.cpp:93

References simple_linked_list::l, and simple_linked_list_size().

Referenced by capture_filter_destroy(), check_message(), cleanup_frames(), delay_done(), delay_postprocess(), delay_reconfigure(), display_sdl2_getf(), enqueue_all_finished_frames(), flush_captured_data(), master_worker(), module_done(), process_message(), send_message_common(), udp_exit(), udp_recvfrom_data(), vidcap_file_grab(), vidcap_file_process_audio_pkt(), vidcap_swmix_done(), vidcap_syphon_done(), vidcap_syphon_grab(), and worker().

Here is the call graph for this function:

◆ simple_linked_list_prepend()

void simple_linked_list_prepend ( struct simple_linked_list * l,
void * data )

Definition at line 63 of file list.cpp.

64{
65 l->l.push_front(data);
66}

References simple_linked_list::l.

Referenced by vidcap_file_process_audio_pkt().

◆ simple_linked_list_remove()

bool simple_linked_list_remove ( struct simple_linked_list * l,
void * item )
Return values
trueif removed
falseif not found

Definition at line 144 of file list.cpp.

145{
146 for (auto it = l->l.begin(); it != l->l.end(); ++it) {
147 if (*it == item) {
148 l->l.erase(it);
149 return true;
150 }
151 }
152 return false;
153}
Definition hd-rum.c:27

References simple_linked_list::l.

Referenced by module_check_undelivered_messages(), and module_done().

◆ simple_linked_list_remove_index()

void * simple_linked_list_remove_index ( struct simple_linked_list * l,
int index )
Return values
pointerpointer to removed value
NULLif not found

Definition at line 155 of file list.cpp.

156{
157 int i = 0;
158 for (auto it = l->l.begin(); it != l->l.end(); ++it) {
159 if (i++ == index) {
160 void *ret = *it;
161 l->l.erase(it);
162 return ret;
163 }
164 }
165 return nullptr;
166}

References simple_linked_list::l.

Referenced by process_message().

◆ simple_linked_list_size()