]> git.saurik.com Git - cycript.git/blobdiff - List.hpp
Improve isolation of ObjectiveC syntax filter code.
[cycript.git] / List.hpp
index 92d64e11d3bd1a7444b955b594037bb35683417e..6fd07312729b054a8486cfe9123baadb4ee5d4ae 100644 (file)
--- a/List.hpp
+++ b/List.hpp
@@ -42,15 +42,25 @@ struct CYNext {
 };
 
 template <typename Type_>
 };
 
 template <typename Type_>
-void CYSetLast(Type_ *&list, Type_ *item) {
+Type_ *&CYSetLast(Type_ *&list) {
     if (list == NULL)
     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 <typename Type_>
+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) \
 }
 
 #define CYForEach(value, list) \