image: function image_list_add will add image to the end of list
This commit is contained in:
1 parent
ef4a506905
commit
3fed685e79
1 file changed
+11
-10
+11
-10
@@ -317,21 +317,22 @@ size_t image_read(struct image * image, void * buf, size_t count) {
|
|||||||
void image_list_add(struct image_list ** list, struct image * image) {
|
void image_list_add(struct image_list ** list, struct image * image) {
|
||||||
|
|
||||||
IMAGE_CHECK(image);
|
IMAGE_CHECK(image);
|
||||||
struct image_list * first = calloc(1, sizeof(struct image_list));
|
struct image_list * last = calloc(1, sizeof(struct image_list));
|
||||||
if ( ! first )
|
if ( ! last )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
first->image = image;
|
last->image = image;
|
||||||
first->next = *list;
|
|
||||||
|
|
||||||
if ( *list ) {
|
if ( ! *list ) {
|
||||||
first->prev = (*list)->prev;
|
*list = last;
|
||||||
if ( (*list)->prev )
|
return;
|
||||||
(*list)->prev->next = first;
|
|
||||||
(*list)->prev = first;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*list = first;
|
while ( (*list)->next )
|
||||||
|
list = &((*list)->next);
|
||||||
|
|
||||||
|
last->prev = *list;
|
||||||
|
(*list)->next = last;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user