home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / AS11.ZIP / MFWD.C < prev    next >
C/C++ Source or Header  |  1986-11-01  |  1KB  |  69 lines

  1. /*
  2.  *      in memory version of forward ref handler
  3.  */
  4.  
  5. #define MAXFWD  500
  6.  
  7. struct fref{
  8.  int     f_fno;  /* file number */
  9.  int     f_line; /* line number */
  10.  };
  11.  
  12. struct fref *Fbase = NULL;
  13. struct fref *Fnext = NULL;
  14. int Fleft = 0;
  15.  
  16. /*
  17.  *      fwdinit --- initialize forward ref array
  18.  */
  19. fwdinit()
  20. {
  21.  char *malloc();
  22.  
  23.  Fbase = (struct fref *)malloc( sizeof(struct fref) * MAXFWD );
  24.  if( Fbase == (struct fref *)NULL )
  25.   fatal("No mem for fwd refs");
  26.  Fnext = Fbase;
  27.  Fleft = MAXFWD-1;
  28. }
  29.  
  30. /*
  31.  *      fwdreinit --- reinitialize forward ref file
  32.  */
  33. fwdreinit()
  34. {
  35.  Fnext->f_fno = Fnext->f_line = 0;
  36.  Fnext = Fbase;
  37.  Ffn = Fnext->f_fno;
  38.  F_ref = Fnext->f_line;
  39.  Fnext++;
  40. }
  41.  
  42. /*
  43.  *      fwdmark --- mark current file/line as containing a forward ref
  44.  */
  45. fwdmark()
  46. {
  47.  if( Fleft != 0 ){
  48.   Fnext->f_fno = Cfn;
  49.   Fnext->f_line = Line_num;
  50.   Fnext++;
  51.   Fleft--;
  52.   }
  53.  else
  54.   error("No space for fwd refs");
  55. }
  56.  
  57. /*
  58.  *      fwdnext --- get next forward ref
  59.  */
  60. fwdnext()
  61. {
  62.  Ffn = Fnext->f_fno;
  63.  F_ref = Fnext->f_line;
  64.  Fnext++;
  65. #ifdef DEBUG
  66.  printf("Next Fwd ref: %d,%d\n",Ffn,F_ref);
  67. #endif
  68. }
  69.