home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / emacs / src / lfree.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-07  |  1.3 KB  |  56 lines

  1. #include    "stdio.h"
  2. #include    "ed.h"
  3.  
  4. /*
  5.  * Delete line "lp". Fix all of the
  6.  * links that might point at it (they are
  7.  * moved to offset 0 of the next line.
  8.  * Unlink the line from whatever buffer it
  9.  * might be in. Release the memory. The
  10.  * buffers are updated too; the magic conditions
  11.  * described in the above comments don't hold
  12.  * here.
  13.  */
  14. lfree(lp)
  15. LINE    *lp;
  16. {
  17.     register BUFFER    *bp;
  18.     register WINDOW    *wp;
  19. #define wp ((WINDOW *)bp)
  20. #define llfp (*(LINE **)0xac)
  21.     register LINE * lp1;
  22.  
  23.     bp = wheadp;
  24.     llfp = ( lp1 = lp )->l_fp;
  25.     while (wp != NULL)
  26.     {    if ( wp->w_linep == lp1 )
  27.             wp->w_linep = llfp;
  28.         if ( wp->w_dotp  == lp1 )
  29.         {    wp->w_dotp  = llfp;
  30.             wp->w_doto  = 0;
  31.         }
  32.         if ( wp->w_markp == lp1 )
  33.         {    wp->w_markp = llfp;
  34.             wp->w_marko = 0;
  35.         }
  36.         wp = wp->w_wndp;
  37.     }
  38.     bp = bheadp;
  39.     while (bp != NULL)
  40.     {    /* if ( bp->b_nwnd == 0 ) */
  41.         /* { */    if ( bp->b_dotp  == lp1 )
  42.             {    bp->b_dotp = llfp;
  43.                 bp->b_doto = 0;
  44.             }
  45.             if ( bp->b_markp == lp1 )
  46.             {    bp->b_markp = llfp;
  47.                 bp->b_marko = 0;
  48.             }
  49.         /* } */
  50.         bp = bp->b_bufp;
  51.     }
  52.     lp1->l_bp->l_fp = llfp;
  53.     llfp->l_bp = lp->l_bp;
  54.     free((char *) lp1);
  55. }
  56.