Exemplo n.º 1
0
void Object_Chunk::destroy(File_Chunk * fc)
{
	List<Chunk *> cl;
	fc->lookup_child("RBOBJECT",cl);
	
	for (LIF<Chunk *> cli(&cl); !cli.done(); cli.next())
	{
		Object_Chunk * ob = (Object_Chunk *)cli();
		if (ob == this) continue;
		
		VModule_Array_Chunk * vmac = ob->get_vmod_chunk();
		
		BOOL in_object_va = FALSE;
		
		if (vmac)
		{
			int pos=0;
			for(int i=0;i<vmac->num_array_items;i++)
			{
								
				if (vmac->vmod_array[i].object_index==object_data.index_num)
				{
					in_object_va=TRUE;
					//update branch indeces for branches that go beyond this point
					for(int j=0;j<vmac->num_array_items;j++)
					{
						if(vmac->vmod_array[j].branch_no> pos)
							vmac->vmod_array[j].branch_no--;
					}		
				}
				else
				{
					if(pos!=i)
					{
						vmac->vmod_array[pos]=vmac->vmod_array[i];
					}
					pos++;
				}					
			}

			if(in_object_va)
			{
				if(pos==0)
				{
					delete vmac;
				}
				else
				{
					//excess entries should be properly deleted when the array is deleted
					vmac->num_array_items=pos;
				}
					
			}
				
		}

		//now remove this object from any adjacency data

		Object_Module_Data_Chunk* omdc=(Object_Module_Data_Chunk*)ob->lookup_single_child("MODULEDT");
		if(omdc)
		{
			Adjacent_Module_Entry_Points_Chunk* amepc=(Adjacent_Module_Entry_Points_Chunk*)omdc->lookup_single_child("ADJMDLEP");
		
			if(amepc)
			{
				for(LIF<Adjacent_Module> ad_lif(&amepc->adjacent_modules_list);!ad_lif.done();)
				{
					if(ad_lif().object_index==object_data.index_num)
						ad_lif.delete_current();
					else
						ad_lif.next();
										
				}
			}
		}
		
		
	}
	
	Shape_Chunk * shp = get_assoc_shape();
	
	deassoc_with_shape (shp);

	lock_chunk(*fc);
	
	deleted = TRUE;

	unlock_chunk(*fc,TRUE);
	
}
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;
}