Changeset 219f52c for view.c


Ignore:
Timestamp:
Jan 23, 2012, 5:27:42 PM (9 years ago)
Author:
Jason Gross <jgross@mit.edu>
Branches:
master, release-1.9
Children:
d126a19
Parents:
ab88b05
git-author:
Jason Gross <jgross@mit.edu> (07/23/11 23:09:55)
git-committer:
Jason Gross <jgross@mit.edu> (01/23/12 17:27:42)
Message:
Allocate owl_messagelist on the heap

This lets us return NULL from owl_global_get_messagelist before the
messagelist has been initilized.

Since g has static duration, g.ml is automatically initialized to NULL.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • view.c

    rf271129 r219f52c  
    66  v->filter=f;
    77  v->style=s;
    8   owl_messagelist_create(&(v->ml));
     8  v->ml = owl_messagelist_new();
    99  owl_view_recalculate(v);
    1010}
     
    1919{
    2020  if (owl_filter_message_match(v->filter, m)) {
    21     owl_messagelist_append_element(&(v->ml), m);
     21    owl_messagelist_append_element(v->ml, m);
    2222  }
    2323}
     
    3030  int i, j;
    3131  const owl_messagelist *gml;
    32   owl_messagelist *ml;
    3332  owl_message *m;
    3433
    3534  gml=owl_global_get_msglist(&g);
    36   ml=&(v->ml);
    3735
    3836  /* nuke the old list, don't free the messages */
    39   owl_messagelist_cleanup(ml, false);
    40   owl_messagelist_create(&(v->ml));
     37  owl_messagelist_delete(v->ml, false);
     38  v->ml = owl_messagelist_new();
    4139
    4240  /* find all the messages we want */
     
    4543    m=owl_messagelist_get_element(gml, i);
    4644    if (owl_filter_message_match(v->filter, m)) {
    47       owl_messagelist_append_element(ml, m);
     45      owl_messagelist_append_element(v->ml, m);
    4846    }
    4947  }
     
    7270owl_message *owl_view_get_element(const owl_view *v, int index)
    7371{
    74   return(owl_messagelist_get_element(&(v->ml), index));
     72  return owl_messagelist_get_element(v->ml, index);
    7573}
    7674
    7775void owl_view_delete_element(owl_view *v, int index)
    7876{
    79   owl_messagelist_delete_element(&(v->ml), index);
     77  owl_messagelist_delete_element(v->ml, index);
    8078}
    8179
    8280void owl_view_undelete_element(owl_view *v, int index)
    8381{
    84   owl_messagelist_undelete_element(&(v->ml), index);
     82  owl_messagelist_undelete_element(v->ml, index);
    8583}
    8684
    8785int owl_view_get_size(const owl_view *v)
    8886{
    89   return(owl_messagelist_get_size(&(v->ml)));
     87  return owl_messagelist_get_size(v->ml);
    9088}
    9189
     
    158156void owl_view_cleanup(owl_view *v)
    159157{
    160   owl_messagelist_cleanup(&v->ml, false);
     158  owl_messagelist_delete(v->ml, false);
    161159  g_free(v->name);
    162160}
Note: See TracChangeset for help on using the changeset viewer.