diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-14 07:22:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-14 07:22:42 +0000 |
commit | 662b5736c37e8cf2b3e6aa5af53cef0d03b743ab (patch) | |
tree | c4299637a2db19a3e87957645d5aa58e196da43f /src/include/gnunet_container_lib.h | |
parent | 94aa63cb17777332095a1de0a70382a49e10fecb (diff) | |
download | gnunet-662b5736c37e8cf2b3e6aa5af53cef0d03b743ab.tar.gz gnunet-662b5736c37e8cf2b3e6aa5af53cef0d03b743ab.zip |
LRN loves slist: Use stack allocation for slist iterator
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r-- | src/include/gnunet_container_lib.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 0c7f60a7a..75443b6ae 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -1054,7 +1054,24 @@ struct GNUNET_CONTAINER_SList; | |||
1054 | /** | 1054 | /** |
1055 | * Handle to a singly linked list iterator | 1055 | * Handle to a singly linked list iterator |
1056 | */ | 1056 | */ |
1057 | struct GNUNET_CONTAINER_SList_Iterator; | 1057 | struct GNUNET_CONTAINER_SList_Iterator |
1058 | { | ||
1059 | /** | ||
1060 | * Linked list that we are iterating over. | ||
1061 | */ | ||
1062 | struct GNUNET_CONTAINER_SList *list; | ||
1063 | |||
1064 | /** | ||
1065 | * Last element accessed. | ||
1066 | */ | ||
1067 | struct GNUNET_CONTAINER_SList_Elem *last; | ||
1068 | |||
1069 | /** | ||
1070 | * Current list element. | ||
1071 | */ | ||
1072 | struct GNUNET_CONTAINER_SList_Elem *elem; | ||
1073 | }; | ||
1074 | |||
1058 | 1075 | ||
1059 | 1076 | ||
1060 | /** | 1077 | /** |
@@ -1113,9 +1130,11 @@ GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l); | |||
1113 | * Return the beginning of a list | 1130 | * Return the beginning of a list |
1114 | * | 1131 | * |
1115 | * @param l list | 1132 | * @param l list |
1116 | * @return iterator pointing to the beginning, free using "GNUNET_free" | 1133 | * @return iterator pointing to the beginning (by value! Either allocate the |
1134 | * structure on the stack, or use GNUNET_malloc() yourself! All other | ||
1135 | * functions do take pointer to this struct though) | ||
1117 | */ | 1136 | */ |
1118 | struct GNUNET_CONTAINER_SList_Iterator * | 1137 | struct GNUNET_CONTAINER_SList_Iterator |
1119 | GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l); | 1138 | GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l); |
1120 | 1139 | ||
1121 | 1140 | ||