Changeset fc8a87a for messagelist.c
- Timestamp:
- Jun 25, 2011, 3:26:15 AM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- f9df2f0
- Parents:
- 12294d2
- git-author:
- David Benjamin <davidben@mit.edu> (03/10/11 14:49:02)
- git-committer:
- David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
messagelist.c
rd427f08 rfc8a87a 3 3 #include <string.h> 4 4 5 intowl_messagelist_create(owl_messagelist *ml)5 void owl_messagelist_create(owl_messagelist *ml) 6 6 { 7 owl_list_create(&(ml->list)); 8 return(0); 7 ml->list = g_ptr_array_new(); 8 } 9 10 void owl_messagelist_cleanup(owl_messagelist *ml, bool free_messages) 11 { 12 if (free_messages) 13 g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL); 14 g_ptr_array_free(ml->list, true); 9 15 } 10 16 11 17 int owl_messagelist_get_size(const owl_messagelist *ml) 12 18 { 13 return (owl_list_get_size(&(ml->list)));19 return ml->list->len; 14 20 } 15 21 16 22 void *owl_messagelist_get_element(const owl_messagelist *ml, int n) 17 23 { 18 return (owl_list_get_element(&(ml->list), n));24 return ml->list->pdata[n]; 19 25 } 20 26 … … 26 32 27 33 first = 0; 28 last = owl_list_get_size(&(ml->list))- 1;34 last = ml->list->len - 1; 29 35 while (first <= last) { 30 36 mid = (first + last) / 2; 31 m = owl_list_get_element(&(ml->list), mid);37 m = ml->list->pdata[mid]; 32 38 msg_id = owl_message_get_id(m); 33 39 if (msg_id == target_id) { … … 44 50 void owl_messagelist_append_element(owl_messagelist *ml, void *element) 45 51 { 46 owl_list_append_element(&ml->list, element);52 g_ptr_array_add(ml->list, element); 47 53 } 48 54 … … 51 57 { 52 58 /* mark a message as deleted */ 53 owl_message_mark_delete( owl_list_get_element(&(ml->list), n));59 owl_message_mark_delete(ml->list->pdata[n]); 54 60 return(0); 55 61 } … … 58 64 { 59 65 /* mark a message as deleted */ 60 owl_message_unmark_delete( owl_list_get_element(&(ml->list), n));66 owl_message_unmark_delete(ml->list->pdata[n]); 61 67 return(0); 62 68 } … … 65 71 { 66 72 /* expunge deleted messages */ 67 int i , j;68 owl_listnewlist;73 int i; 74 GPtrArray *newlist; 69 75 owl_message *m; 70 76 71 owl_list_create(&newlist);77 newlist = g_ptr_array_new(); 72 78 /*create a new list without messages marked as deleted */ 73 j=owl_list_get_size(&(ml->list)); 74 for (i=0; i<j; i++) { 75 m=owl_list_get_element(&(ml->list), i); 79 for (i = 0; i < ml->list->len; i++) { 80 m = ml->list->pdata[i]; 76 81 if (owl_message_is_delete(m)) { 77 82 owl_message_delete(m); 78 83 } else { 79 owl_list_append_element(&newlist, m);84 g_ptr_array_add(newlist, m); 80 85 } 81 86 } 82 87 83 88 /* free the old list */ 84 owl_list_cleanup(&(ml->list), NULL);89 g_ptr_array_free(ml->list, true); 85 90 86 91 /* copy the new list to the old list */ … … 92 97 void owl_messagelist_invalidate_formats(const owl_messagelist *ml) 93 98 { 94 int i , j;99 int i; 95 100 owl_message *m; 96 101 97 j=owl_list_get_size(&(ml->list)); 98 for (i=0; i<j; i++) { 99 m=owl_list_get_element(&(ml->list), i); 102 for (i = 0; i < ml->list->len; i++) { 103 m = ml->list->pdata[i]; 100 104 owl_message_invalidate_format(m); 101 105 }
Note: See TracChangeset
for help on using the changeset viewer.