예제 #1
0
/* Free IBO object */
int dlFreeIBO( dlIBO *ibo )
{
   CALL("%p", ibo);

   /* Fuuuuuuuuu--- We have non valid object */
   if(!ibo) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   /* There is still references to this object alive */
   if(--ibo->refCounter != 0) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   dlSetAlloc( ALLOC_IBO );

   /* Free all data */
   dlFreeIndexBuffer( ibo );

   /* delete ibo */
   if( ibo->object ) glDeleteBuffers(1, &ibo->object);
   ibo->object = 0;

   LOGFREE("FREE");

   /* Free IBO object */
   dlFree( ibo, sizeof(dlIBO) );

   RET("%d", RETURN_OK);
   return( RETURN_OK );
}
예제 #2
0
/* Free scene object */
int dlFreeObject( dlObject *object )
{
   unsigned int i;
   CALL("%p", object);

   /* Fuuuuuuuuu--- We have non valid object */
   if(!object) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   /* Free material ( if any ) */
   if(dlFreeMaterial( object->material ) == RETURN_OK)
      object->material = NULL;

   /* Free VBO Object */
   if(dlFreeVBO( object->vbo )           == RETURN_OK)
      object->vbo = NULL;

   /* Free IBO Object */
   if(dlFreeIBO( object->ibo )           == RETURN_OK)
      object->ibo = NULL;

   /* free animator if there is one */
   if(object->animator)
   { if( dlFreeAnimator( object->animator ) == RETURN_OK ); object->animator = NULL; }

   /* Free as in, decrease reference on childs */
   i = 0;
   for(; i != object->num_childs; ++i)
   {
      if(dlFreeObject( object->child[i] ) == RETURN_OK)
         object->child[i] = NULL;
   }

   /* There is still references to this object alive */
   if(--object->refCounter != 0) return( RETURN_NOTHING );

   dlSetAlloc( ALLOC_SCENEOBJECT );

   /* Free child list */
   dlFree( object->child, object->num_childs * sizeof(dlObject*) );
   object->child = NULL;
   object->num_childs = 0;

   LOGFREE("FREE");

   /* Free scene object */
   dlFree( object, sizeof(dlObject) );

   RET("%d", RETURN_OK);
   return( RETURN_OK );
}
예제 #3
0
int dlFreeAnimTick( dlAnimTick *animTick )
{
   dlAnimTickOldNode    *oldNode, *nextOldNode;
   dlNodeAnim           *node;
   CALL("%p", animTick);

   /* invalid object */
   if(!animTick)
   { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   dlSetAlloc( ALLOC_EVALUATOR );

   /* we should have animation */
   if(animTick->anim)
   {
      /* free nodes */
      oldNode = animTick->oldNode;
      node    = animTick->anim->node;
      while(oldNode)
      {
         /* free stored pointers */
         dlFree( oldNode->translation,
                 node->num_translation * sizeof(dlVectorKey*) );
         dlFree( oldNode->rotation,
                 node->num_rotation    * sizeof(dlQuatKey*)   );
         dlFree( oldNode->scaling,
                 node->num_scaling     * sizeof(dlVectorKey*) );

         node = node->next;

         /* free node */
         nextOldNode = oldNode->next;
         dlFree( oldNode, sizeof(dlAnimTickOldNode) );
         oldNode = nextOldNode;
      }
      animTick->oldNode = NULL;
   }

   LOGFREE("FREE");

   /* free ticker */
   dlFree( animTick, sizeof(dlAnimTick) );
   animTick = NULL;

   RET("%d", RETURN_OK);
   return( RETURN_OK );
}
예제 #4
0
void
T(free)(void *chunk, const char *here, long lineno)
{
	track_list *list;
	track_data *track;

	if (chunk == NULL) {
		LOGFREE(chunk, here, lineno);
		return;
	}

	track = &((track_data *) chunk)[-1];
	LOGTRACKAT(track, here, lineno);

	/* Check the pointer and core data are valid. */	
	if (track->crc != TRACK_CRC(track)) {
		/* The rest of the data is suspect. */
		(void) fprintf(stderr, HERE_FMT "buffer under run or bad pointer!\n", HERE_ARG);
		abort();
	}

	/* Did something run into us from below? */
	if (track->lo_guard != lo_guard) {
		(void) fprintf(
			stderr, HERE_FMT "buffer guard corrupted! size=%zu %s:%ld\n", HERE_ARG,
			track->size, track->here, track->lineno
		);
		abort();
	}
	
	/* Maintain list of allocated memory per thread, including main() */
	list = pthread_getspecific(thread_key);
	if (track->prev == NULL)
		list->head = track->next;
	else
		track->prev->next = track->next;		
	if (track->next != NULL)
		track->next->prev = track->prev;
	(void) pthread_setspecific(thread_key, list);	

	(free)(track);

	(void) LOCK_LOCK(&lock);
	free_count++;
	(void) LOCK_UNLOCK(&lock);			
}
예제 #5
0
/* Free VBO object */
int dlFreeVBO( dlVBO *vbo )
{
   unsigned int i;
   CALL("%p", vbo);

   /* Fuuuuuuuuu--- We have non valid object */
   if(!vbo) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   /* There is still references to this object alive */
   if(--vbo->refCounter != 0) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   dlSetAlloc( ALLOC_VBO );

   /* Free all data */
   i = 0;
   for(;i != _dlCore.info.maxTextureUnits; ++i)
      dlFreeCoordBuffer( vbo, i );
   dlFree( vbo->uvw, _dlCore.info.maxTextureUnits * sizeof(dlUVW) );

   if(vbo->tstance) free(vbo->tstance);
   dlFreeVertexBuffer( vbo );
   dlFreeNormalBuffer( vbo );
#if VERTEX_COLOR
   dlFreeColorBuffer( vbo );
#endif

   /* delete vbo */
   if( vbo->object ) glDeleteBuffers(1, &vbo->object);
   vbo->object = 0;

   LOGFREE("FREE");

   /* Free VBO object */
   dlFree( vbo, sizeof(dlVBO) );

   RET("%d", RETURN_OK);
   return( RETURN_OK );
}
예제 #6
0
/* Free camera */
int dlFreeCamera( dlCamera *object )
{
   CALL("%p", object);

   /* Fuuuuuuuuu--- We have non valid object */
   if(!object) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   /* There is still references to this object alive */
   if(--object->refCounter != 0) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   dlSetAlloc( ALLOC_CAMERA );

   /* Check if this is active */
   if(dlGetCamera() == object)
      dlSetCamera( NULL );

   LOGFREE("FREE");

   /* Free camera */
   dlFree( object, sizeof(dlCamera) );
   RET("%d", RETURN_OK);
   return( RETURN_OK );
}
예제 #7
0
/* free atlas */
int dlFreeAtlas( dlAtlas *atlas )
{
   unsigned int i;
   CALL("%p", atlas);

   /* non valid */
   if(!atlas)
   { RET("%d", RETURN_FAIL); return( RETURN_FAIL ); }

   /* Free as in, decrease reference on childs */
   i = 0;
   for(; i != atlas->num_textures; ++i)
   {
      if(dlFreeTexture( atlas->rect[i].texture ) == RETURN_OK)
         atlas->rect[i].texture = NULL;
   }

   /* Free combined atlas texture */
   dlFreeTexture( atlas->texture );

   /* still hold reference? */
   if(--atlas->refCounter != 0)
   { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   dlSetAlloc( ALLOC_ATLAS );

   /* free everything */
   dlFree( atlas->rect, atlas->num_textures * sizeof(dlAtlasRect) );
   atlas->rect          = NULL;
   atlas->num_textures  = 0;

   LOGFREE("FREE");
   dlFree( atlas, sizeof(dlAtlas) );

   RET("%d", RETURN_OK);
   return( RETURN_OK );
}
예제 #8
0
/* Free material object */
int dlFreeMaterial( dlMaterial *object )
{
   CALL("%p", object);

   /* Fuuuuuuuuu--- We have non valid object */
   if(!object) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   /* Free texture */
   if(dlFreeTexture( object->texture ) == RETURN_OK)
      object->texture = NULL;

   /* There is still references to this object alive */
   if(--object->refCounter != 0) { RET("%d", RETURN_NOTHING); return( RETURN_NOTHING ); }

   dlSetAlloc( ALLOC_MATERIAL );

   LOGFREE("FREE");

   /* Free scene object */
   dlFree( object, sizeof(dlMaterial) );

   RET("%d", RETURN_OK);
   return( RETURN_OK );
}