Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • messagelist.c

    r67b959c r901cee9  
    2222void *owl_messagelist_get_element(const owl_messagelist *ml, int n)
    2323{
     24  /* we assume things like owl_view_get_element(v, owl_global_get_curmsg(&g))
     25   * work even when there are no messages in the message list.  So don't
     26   * segfault if someone asks for the zeroth element of an empty list.
     27   */
     28  if (n >= ml->list->len) return NULL;
    2429  return ml->list->pdata[n];
    2530}
    2631
    27 int owl_messagelist_get_index_by_id(const owl_messagelist *ml, int target_id)
     32owl_message *owl_messagelist_get_by_id(const owl_messagelist *ml, int target_id)
    2833{
    29   /* return the message index with id == 'id'.  If it doesn't exist return -1. */
     34  /* return the message with id == 'id'.  If it doesn't exist return NULL. */
    3035  int first, last, mid, msg_id;
    3136  owl_message *m;
     
    3843    msg_id = owl_message_get_id(m);
    3944    if (msg_id == target_id) {
    40       return mid;
     45      return(m);
    4146    } else if (msg_id < target_id) {
    4247      first = mid + 1;
     
    4550    }
    4651  }
    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];
     52  return(NULL);
    5653}
    5754
     
    7471  owl_message_unmark_delete(ml->list->pdata[n]);
    7572  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));
    8173}
    8274
Note: See TracChangeset for help on using the changeset viewer.