From dea644bbd65b6cc2d60956ff2be1399f63ac1782 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 4 Mar 2010 20:02:22 +0100 Subject: Added a prepend function for ssh_list. --- libssh/misc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libssh') 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; -- cgit