Changeset 9190285


Ignore:
Timestamp:
Sep 18, 2010, 5:07:40 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
c394de8
Parents:
08263a8
git-author:
David Benjamin <davidben@mit.edu> (08/14/10 00:54:38)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 17:07:40)
Message:
Ref-count the editwin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r9eb38bb r9190285  
    26932693
    26942694  owl_global_set_typwin_inactive(&g);
    2695   owl_editwin_delete(e);
     2695  owl_editwin_unref(e);
    26962696}
    26972697
     
    27502750
    27512751  owl_editwin_do_callback(e);
    2752   owl_editwin_delete(e);
     2752  owl_editwin_unref(e);
    27532753}
    27542754
  • editwin.c

    r08263a8 r9190285  
    1717
    1818struct _owl_editwin { /*noproto*/
     19  int refcount;
    1920  char *buff;
    2021  owl_history *hist;
     
    7475  e = owl_malloc(sizeof(owl_editwin));
    7576  memset(e, 0, sizeof(*e));
     77  e->refcount = 1;
    7678  return e;
    7779}
    7880
    79 void owl_editwin_delete(owl_editwin *e)
     81static void _owl_editwin_delete(owl_editwin *e)
    8082{
    8183  if (e->win) {
     
    153155  oe_set_window(e, win, winlines, wincols);
    154156  return e;
     157}
     158
     159owl_editwin *owl_editwin_ref(owl_editwin *e)
     160{
     161  e->refcount++;
     162  return e;
     163}
     164
     165void owl_editwin_unref(owl_editwin *e)
     166{
     167  e->refcount--;
     168  if (e->refcount <= 0)
     169    _owl_editwin_delete(e);
    155170}
    156171
  • tester.c

    r7ba2ad4 r9190285  
    390390                                                            "blah"));
    391391
    392   owl_editwin_delete(oe); oe = NULL;
     392  owl_editwin_unref(oe); oe = NULL;
    393393  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
    394394
     
    403403                                                            "blah"));
    404404
    405   owl_editwin_delete(oe); oe = NULL;
     405  owl_editwin_unref(oe); oe = NULL;
    406406
    407407  /* Test owl_editwin_move_to_beginning_of_line. */
     
    425425  FAIL_UNLESS("find beginning of line after empty middle line",
    426426              owl_editwin_move_to_beginning_of_line(oe) == -2);
    427   owl_editwin_delete(oe); oe = NULL;
     427  owl_editwin_unref(oe); oe = NULL;
    428428
    429429  printf("# END testing owl_editwin (%d failures)\n", numfailed);
Note: See TracChangeset for help on using the changeset viewer.