[PATCH] Add example for howto use the sort function.

Wilfried Goesgens <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
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
add_example.diff (text/plain, 703 B)
--- 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 *));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.