Changeset 67b959c for messagelist.c
- Timestamp:
- Jun 25, 2011, 10:01:22 AM (13 years ago)
- Children:
- caac19d
- Parents:
- b2bfe1f
- git-author:
- Jason Gross <jgross@mit.edu> (05/23/11 19:06:48)
- git-committer:
- Jason Gross <jgross@mit.edu> (06/25/11 10:01:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
messagelist.c
rfc8a87a r67b959c 25 25 } 26 26 27 owl_message *owl_messagelist_get_by_id(const owl_messagelist *ml, int target_id)27 int owl_messagelist_get_index_by_id(const owl_messagelist *ml, int target_id) 28 28 { 29 /* return the message with id == 'id'. If it doesn't exist return NULL. */29 /* return the message index with id == 'id'. If it doesn't exist return -1. */ 30 30 int first, last, mid, msg_id; 31 31 owl_message *m; … … 38 38 msg_id = owl_message_get_id(m); 39 39 if (msg_id == target_id) { 40 return (m);40 return mid; 41 41 } else if (msg_id < target_id) { 42 42 first = mid + 1; … … 45 45 } 46 46 } 47 return(NULL); 47 return -1; 48 } 49 50 owl_message *owl_messagelist_get_by_id(const owl_messagelist *ml, int target_id) 51 { 52 /* return the message with id == 'id'. If it doesn't exist return NULL. */ 53 int n = owl_messagelist_get_index_by_id(ml, target_id); 54 if (n < 0) return NULL; 55 return ml->list->pdata[n]; 48 56 } 49 57 … … 66 74 owl_message_unmark_delete(ml->list->pdata[n]); 67 75 return(0); 76 } 77 78 void owl_messagelist_delete_and_expunge_element(owl_messagelist *ml, int n) 79 { 80 owl_message_delete(g_ptr_array_remove_index(ml->list, n)); 68 81 } 69 82
Note: See TracChangeset
for help on using the changeset viewer.