Diff for /gforth/engine/main.c between versions 1.129 and 1.130

version 1.129, 2003/11/06 10:23:31 version 1.130, 2003/11/06 21:59:49
Line 267  unsigned char *branch_targets(Cell *imag Line 267  unsigned char *branch_targets(Cell *imag
                               int size, Cell base)                                int size, Cell base)
      /* produce a bitmask marking all the branch targets */       /* produce a bitmask marking all the branch targets */
 {  {
   int i=0, j, k, steps=(size/sizeof(Cell))/RELINFOBITS;    int i=0, j, k, steps=(((size-1)/sizeof(Cell))/RELINFOBITS)+1;
   Cell token;    Cell token;
   unsigned char bits;    unsigned char bits;
   unsigned char *result=malloc(steps+1);    unsigned char *result=malloc(steps);
     
   memset(result, 0, steps+1);    memset(result, 0, steps);
   for(k=0; k<=steps; k++) {    for(k=0; k<steps; k++) {
     for(j=0, bits=bitstring[k]; j<RELINFOBITS; j++, i++, bits<<=1) {      for(j=0, bits=bitstring[k]; j<RELINFOBITS; j++, i++, bits<<=1) {
       if((i < size) && (bits & (1U << (RELINFOBITS-1)))) {        if(bits & (1U << (RELINFOBITS-1))) {
           assert(i*sizeof(Cell) < size);
         token=image[i];          token=image[i];
         if (token>=base) { /* relocatable address */          if (token>=base) { /* relocatable address */
           UCell bitnum=(token-base)/sizeof(Cell);            UCell bitnum=(token-base)/sizeof(Cell);
Line 290  unsigned char *branch_targets(Cell *imag Line 291  unsigned char *branch_targets(Cell *imag
 void relocate(Cell *image, const unsigned char *bitstring,   void relocate(Cell *image, const unsigned char *bitstring, 
               int size, Cell base, Label symbols[])                int size, Cell base, Label symbols[])
 {  {
   int i=0, j, k, steps=(size/sizeof(Cell))/RELINFOBITS;    int i=0, j, k, steps=(((size-1)/sizeof(Cell))/RELINFOBITS)+1;
   Cell token;    Cell token;
   char bits;    char bits;
   Cell max_symbols;    Cell max_symbols;
Line 317  void relocate(Cell *image, const unsigne Line 318  void relocate(Cell *image, const unsigne
   for (max_symbols=0; symbols[max_symbols]!=0; max_symbols++)    for (max_symbols=0; symbols[max_symbols]!=0; max_symbols++)
     ;      ;
   max_symbols--;    max_symbols--;
   size/=sizeof(Cell);  
   
   for(k=0; k<=steps; k++) {    for(k=0; k<steps; k++) {
     for(j=0, bits=bitstring[k]; j<RELINFOBITS; j++, i++, bits<<=1) {      for(j=0, bits=bitstring[k]; j<RELINFOBITS; j++, i++, bits<<=1) {
       /*      fprintf(stderr,"relocate: image[%d]\n", i);*/        /*      fprintf(stderr,"relocate: image[%d]\n", i);*/
       if((i < size) && (bits & (1U << (RELINFOBITS-1)))) {        if(bits & (1U << (RELINFOBITS-1))) {
           assert(i*sizeof(Cell) < size);
         /* fprintf(stderr,"relocate: image[%d]=%d of %d\n", i, image[i], size/sizeof(Cell)); */          /* fprintf(stderr,"relocate: image[%d]=%d of %d\n", i, image[i], size/sizeof(Cell)); */
         token=image[i];          token=image[i];
         if(token<0) {          if(token<0) {

Removed from v.1.129  
changed lines
  Added in v.1.130


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>