mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
Added a prepend function for ssh_list.
This commit is contained in:
@@ -47,6 +47,7 @@ struct ssh_list *ssh_list_new(void);
|
||||
void ssh_list_free(struct ssh_list *list);
|
||||
struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list);
|
||||
int ssh_list_add(struct ssh_list *list, const void *data);
|
||||
int ssh_list_prepend(struct ssh_list *list, const void *data);
|
||||
void ssh_list_remove(struct ssh_list *list, struct ssh_iterator *iterator);
|
||||
|
||||
const void *_ssh_list_pop_head(struct ssh_list *list);
|
||||
|
||||
@@ -237,6 +237,25 @@ int ssh_list_add(struct ssh_list *list,const void *data){
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
int ssh_list_prepend(struct ssh_list *list, const void *data){
|
||||
struct ssh_iterator *it = ssh_iterator_new(data);
|
||||
|
||||
if (it == NULL) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
if (list->end == NULL) {
|
||||
/* list is empty */
|
||||
list->root = list->end = it;
|
||||
} else {
|
||||
/* set as new root */
|
||||
it->next = list->root;
|
||||
list->root = it;
|
||||
}
|
||||
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
void ssh_list_remove(struct ssh_list *list, struct ssh_iterator *iterator){
|
||||
struct ssh_iterator *ptr,*prev;
|
||||
prev=NULL;
|
||||
|
||||
Reference in New Issue
Block a user