void cTexturedQuadFactory::RemoveReference(cQuadInfo& info)
	{
		AKJ_ASSERT(info.mReferences >0);
		if(--info.mReferences == 0)
		{
			DestroyInfo(info);
		}
	}
Example #2
0
int HashDestroy(HashTable ht, void *data)
/* Removes the record containing 'data' from ht and DESTROYS data. 
   If no such record exists, it returns 0. On success 1 is returned. */
{
  int retval=0;
  HashInfoPtr tmp;
  unsigned int hashval = ht->calcIndx(data)%ht->size; 

  ErrPushFunc("HashDestroy");
  if(ht->infoArray[hashval]!=NULL) {
    if(!(ht->compData(ht->infoArray[hashval]->data, data))) {
      HashInfoPtr toTrash;             /*First record matched -- remove it! */
      toTrash=ht->infoArray[hashval];
      ht->infoArray[hashval]=toTrash->next;
      DestroyInfo(ht, toTrash);
      ht->elementCount--;

      assert( ht->elementCount >= 0 );

      retval=1;
    }
    else {
      for( tmp = ht->infoArray[hashval];      /* Continue search for match */
           (tmp->next!=NULL) && (ht->compData(tmp->next->data, data));
           tmp = tmp->next )
        ;

      if(tmp->next!=NULL) {      /* If found, remove the matching record. */
        HashInfoPtr toTrash;
        toTrash = tmp->next;
        tmp->next = toTrash->next;
        DestroyInfo(ht, toTrash);
        ht->elementCount--;
        assert( ht->elementCount >= 0 );
        retval=1;
      }
    }
  }
  ErrPopFunc();
  return(retval);
}
Example #3
0
void HashDestroyTable(HashTable ht)
{
  unsigned int i;
  HashInfoPtr tmp, tmp2;

  ErrPushFunc("HashDestroyTable");
  for(i=0; i < ht->size; i++)
    for(tmp=ht->infoArray[i]; tmp!=NULL; ) 
    {
      /* erl 990412. DestroyInfo frees its second parameter, so we cannot reuse
         it by looking at its ->next after DestroyInfo has been called. */
      tmp2 = tmp;
      tmp = tmp->next;
      
      DestroyInfo(ht, tmp2);
    }
  
  free(ht);
  ErrPopFunc();
}