While using the list sort function i've stepped into some traps.
To stop others from doing the same, here's a patch, that adds
a tiny sample-sort function to the documentation of the header.
Wilfried G?sgens
--- a/gateway/gwlib/list.h 2005-02-11 16:35:48.000000000 +0100
+++ b/gateway/gwlib/list.h 2006-04-04 16:22:40.000000000 +0200
@@ -293,6 +305,16 @@
/*
* Sort the list with qsort.
+ * if you have a list that you feed like that:
+ * Msg *message;
+ * gwlist_add(mylist, (void*) message);
+ * a function that could sort messages by their data length would look like
that:
+ * int sort_by_messagelength(void* first_msg_pp, void* second_msg_pp)
+ *{
+ * Msg *first_msg=*(Msg**)first_msg_pp;
+ * Msg *second_msg=*(Msg**)second_msg_pp;
+ * return
octstr_len(first_msg->sms.msgdata)-octstr_len(second_msg->sms.msgdata);
+ *}
*/
void gwlist_sort(List *list, int(*cmp)(const void *, const void *));