X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/da2af935087da0e425bbfb06fe1cc24107e3f32d..6b9e29d28c4754efd5fcafddd291930bbade6b8a:/List.hpp diff --git a/List.hpp b/List.hpp index 7113492..6fd0731 100644 --- a/List.hpp +++ b/List.hpp @@ -1,5 +1,5 @@ /* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2010 Jay Freeman (saurik) + * Copyright (C) 2009-2012 Jay Freeman (saurik) */ /* GNU Lesser General Public License, Version 3 {{{ */ @@ -42,15 +42,25 @@ struct CYNext { }; template -void CYSetLast(Type_ *&list, Type_ *item) { +Type_ *&CYSetLast(Type_ *&list) { if (list == NULL) - list = item; - else { - Type_ *next(list); - while (next->next_ != NULL) - next = next->next_; - next->next_ = item; - } + return list; + + Type_ *next(list); + while (next->next_ != NULL) + next = next->next_; + return next->next_; +} + +template +Type_ *CYGetLast(Type_ *list) { + if (list == NULL) + return NULL; + + Type_ *next(list); + while (next->next_ != NULL) + next = next->next_; + return next; } #define CYForEach(value, list) \