Exemplo n.º 1
0
void Memo_Write2h(char* cp, long iVal) {
	char buf[10];
	StrIToH(buf, iVal);
	MemoWriteLen(cp, StrLen(cp));
	MemoWriteLen(buf, StrLen(buf));
}
Exemplo n.º 2
0
static int
find_cache_item(unsigned rec_num,int assign_uncompressed)
{int i=cache_head,d=get_current_db_idx(),idle_item=(cache_head+1)&cache_length_mask;
 if(assign_uncompressed)uncompressed=0;
 if(saved_uncompressed&&cache[idle_item].chunk.d>=0
    &&saved_uncompressed==cache[idle_item].content)
  idle_item=(idle_item+1)&cache_length_mask; 
 if(facunde)
 {char s[0x33];StrCopy(s,"cache find ");StrCat(s,"(");
  StrIToA(s+StrLen(s),d);StrCat(s,":");
  StrIToA(s+StrLen(s),rec_num);StrCat(s,")");
  draw_chars(s,0,0);
 }
 do
 {if(facunde)
  {char s[0x33];StrCopy(s,"cache ");StrIToA(s+StrLen(s),i);StrCat(s,":(");
   StrIToA(s+StrLen(s),cache[i].db_idx);StrCat(s,":");
   StrIToA(s+StrLen(s),cache[i].rec_num);StrCat(s,");");
   StrIToA(s+StrLen(s),cache[i].chunk.d);StrCat(s,"  ");
   draw_chars(s,0,0);
  }
  if(cache[i].chunk.d<0){idle_item=i;goto next_i;}
  if(d==cache[i].db_idx&&rec_num==cache[i].rec_num)
  {if(facunde)
   {char s[0x33];StrCopy(s,"found ");StrCat(s," ");
    StrIToA(s+StrLen(s),i);StrCat(s,":(");
    StrIToA(s+StrLen(s),d);StrCat(s,":");
    StrIToA(s+StrLen(s),rec_num);StrCat(s,")");
    StrIToH(s+StrLen(s),(UInt32)(cache[i].content));StrCat(s,"  ");
    draw_chars(s,0,0);
   }if(assign_uncompressed)uncompressed=cache[i].content;return i;
  }
  next_i:i=(i-1)&cache_length_mask;
 }while(i!=cache_head);
 if(facunde)
 {char s[0x33];StrCopy(s,"cache loop done ");StrIToA(s+StrLen(s),idle_item);StrCat(s,":(");
   StrIToA(s+StrLen(s),cache[idle_item].db_idx);StrCat(s,":");
   StrIToA(s+StrLen(s),cache[idle_item].rec_num);StrCat(s,");");
   StrIToA(s+StrLen(s),cache[idle_item].chunk.d);StrCat(s,"  ");
   draw_chars(s,0,0);
 }
 if(cache[idle_item].chunk.d>=0)
 {free_chunk(cache[idle_item].chunk);
  cache[idle_item].chunk.d=invalid_chunk_descriptor;
 }i=(idle_item+1)&cache_length_mask;
 while(i!=idle_item)
 {cache[idle_item].chunk=alloc_chunk(dh.record_size);
  if(cache[idle_item].chunk.d>=0){cache_head=idle_item;break;}
  while(i!=idle_item)
  {int i_prev=i;i=(i+1)&cache_length_mask;
   if(cache[i_prev].chunk.d>=0&&
      (!saved_uncompressed||saved_uncompressed!=cache[i_prev].content))
   {free_chunk(cache[i_prev].chunk);
    cache[i_prev].chunk.d=invalid_chunk_descriptor;break;
   }
  }
 }
 if(facunde)
 {char s[0x33];StrCopy(s,"idle alloc ");StrIToA(s+StrLen(s),idle_item);StrCat(s,":(");
   StrIToA(s+StrLen(s),d);StrCat(s,":");
   StrIToA(s+StrLen(s),rec_num);StrCat(s,");");
   StrIToA(s+StrLen(s),cache[idle_item].chunk.d);StrCat(s,"  ");
   draw_chars(s,0,0);
 }
 if(cache[idle_item].chunk.d>=0)
 {if(inflate_into_chunk(cache[idle_item].chunk))
  {free_chunk(cache[idle_item].chunk);
   cache[idle_item].chunk.d=invalid_chunk_descriptor;
  }else
  {const char*uc=lock_chunk(cache[idle_item].chunk);
   cache[idle_item].rec_num=rec_num;cache[idle_item].db_idx=d;
   cache[idle_item].content=uc;if(assign_uncompressed)uncompressed=uc;
   return idle_item;
  }
 }return-1;
}