X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/8d7447c170dd11c91d0a07768f32a2699177fa54..39ed6a515508c195281495054579ab82f30545e8:/List.hpp?ds=sidebyside diff --git a/List.hpp b/List.hpp index 92d64e1..6fd0731 100644 --- a/List.hpp +++ b/List.hpp @@ -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) \