Exemple #1
0
///
//Frees resuorces allocated by an Asset Buffer
//Deletes data being held in buffer!!
//
//PArameters:
//	buffer: pointer to The buffer to free
static void AssetManager_FreeBuffer(AssetBuffer* buffer)
{
	for (unsigned int i = 0; i < buffer->meshMap->data->capacity; i++)
	{
		struct HashMap_KeyValuePair* pair = *(struct HashMap_KeyValuePair**)DynamicArray_Index(buffer->meshMap->data, i);
		if(pair != NULL)
		{
			Mesh* m = (Mesh*)pair->data;
			Mesh_Free(m);
			//Following line will be done by HashMap_Free
			//HashMap_KeyValuePair_Free(pair);
		}
	}
	printf("Meshes freed\n");
	HashMap_Free(buffer->meshMap);
	printf("MeshMap freed\n");

	for (unsigned int i = 0; i < buffer->textureMap->data->capacity; i++)
	{
		struct HashMap_KeyValuePair* pair = *(struct HashMap_KeyValuePair**)DynamicArray_Index(buffer->textureMap->data, i);
		if(pair != NULL)
		{
			Texture* t = (Texture*)pair->data;
			Texture_Free(t);
		}
	}
	printf("Textures freed.\n");
	HashMap_Free(buffer->textureMap);

	printf("Texture Map Freed.\n");
}
Exemple #2
0
///
//Frees resuorces allocated by an Asset Buffer
//Deletes data being held in buffer!!
//
//PArameters:
//	buffer: pointer to The buffer to free
static void AssetManager_FreeBuffer(AssetBuffer* buffer)
{
	for (int i = 0; i < buffer->meshMap->data->capacity; i++)
	{
		//Mesh_Free((Mesh*)buffer->meshMap->data[i]->data);
		Mesh* m = *(Mesh**)DynamicArray_Index(buffer->meshMap->data, i);
		if(m != NULL)
		{
			Mesh_Free(m);
		}
	}
	HashMap_Free(buffer->meshMap);

	//for (int i = 0; i < buffer->textureMap->size; i++)
	for (int i = 0; i < buffer->textureMap->data->capacity; i++)
	{
		//Texture_Free((Texture*)buffer->meshMap->data[i]->data);
		Texture* t = *(Texture**)DynamicArray_Index(buffer->textureMap->data, i);
		if(t != NULL)
		{
			Texture_Free(t);
		}
	}

	HashMap_Free(buffer->textureMap);
}
Exemple #3
0
///
//Frees the data allocated by an octtree.
//Does not free any of the data contained within the octtree!
//
//Parameters:
//	tree: A pointer to the octtree to free
void OctTree_Free(OctTree* tree)
{
	//Free the nodes
	OctTree_Node_Free(tree, tree->root);
	//Free the root
	free(tree->root);
	//Free the map
	HashMap_Free(tree->map);
	//Free the tree!
	free(tree);
}