diff options
| author | Andreas Schneider <mail@cynapses.org> | 2010-03-04 20:02:22 +0100 |
|---|---|---|
| committer | Andreas Schneider <mail@cynapses.org> | 2010-03-06 12:29:03 +0100 |
| commit | 2144049c7dad4b1584c893dae3303a724c829864 (patch) | |
| tree | a13d5ded0c48c97f440f9be095a0a250b3e4a574 /libssh/misc.c | |
| parent | 9dd86859e8582eefc958a14ba4787c2488730edc (diff) | |
Added a prepend function for ssh_list.
Diffstat (limited to 'libssh/misc.c')
| -rw-r--r-- | libssh/misc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libssh/misc.c b/libssh/misc.c index a86a163b..76f72a72 100644 --- a/libssh/misc.c +++ b/libssh/misc.c @@ -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; |
