CgBittorrentBencodingList *cg_bittorrent_bencodinglist_new()
{
	CgBittorrentBencodingList *cbbList;

	cbbList = (CgBittorrentBencodingList *)malloc(sizeof(CgBittorrentBencodingList));
	if (!cbbList)
		return NULL;

	cg_list_header_init((CgList *)cbbList);

	return cbbList;
}
CgUpnpArgumentList *cg_upnp_argumentlist_new()
{
	CgUpnpArgument *argumentList;

	cg_log_debug_l4("Entering...\n");

	argumentList = (CgUpnpArgument *)malloc(sizeof(CgUpnpArgument));

	if ( NULL != argumentList )
		cg_list_header_init((CgList *)argumentList);

	return argumentList;

	cg_log_debug_l4("Leaving...\n");
}
CgUpnpServiceList *cg_upnp_servicelist_new()
{
    CgUpnpServiceList *serviceList;

    cg_log_debug_l4("Entering...\n");

    serviceList = (CgUpnpServiceList *)malloc(sizeof(CgUpnpServiceList));

    if ( NULL != serviceList )
        cg_list_header_init((CgList *)serviceList);

    return serviceList;

    cg_log_debug_l4("Leaving...\n");
}
CgUpnpIconList *cg_upnp_iconlist_new()
{
	CgUpnpIcon *iconList;

	cg_log_debug_l4("Entering...\n");

	iconList = (CgUpnpIcon *)malloc(sizeof(CgUpnpIcon));

	if ( NULL != iconList )
		cg_list_header_init((CgList *)iconList);

	return iconList;

	cg_log_debug_l4("Leaving...\n");
}
CgUpnpDeviceList *cg_upnp_devicelist_new()
{
	CgUpnpDeviceList *devList;

	cg_log_debug_l4("Entering...\n");

	devList = (CgUpnpDeviceList *)malloc(sizeof(CgUpnpDeviceList));

	if ( NULL != devList )
		cg_list_header_init((CgList *)devList);

	return devList;

	cg_log_debug_l4("Leaving...\n");
}
CgDictionary *cg_dictionary_new()
{
	CgDictionary *dictionaryList;

	cg_log_debug_l4("Entering...\n");

	dictionaryList = (CgDictionary *)malloc(sizeof(CgDictionary));

	if ( NULL != dictionaryList )
	{
		cg_list_header_init((CgList *)dictionaryList);
		dictionaryList->key = NULL;
		dictionaryList->value = NULL;
	}

	cg_log_debug_l4("Leaving...\n");

	return dictionaryList;
}
CgHttpHeaderList *cg_http_headerlist_new()
{
	CgHttpHeaderList *headerList;

	cg_log_debug_l4("Entering...\n");

	headerList = (CgHttpHeaderList *)malloc(sizeof(CgHttpHeaderList));

	if ( NULL != headerList )
	{
		cg_list_header_init((CgList *)headerList);
		headerList->name = NULL;
		headerList->value = NULL;
	}

	return headerList;

	cg_log_debug_l4("Leaving...\n");
}
BOOL cg_http_persistentconnection_init(void)
{
	cg_log_debug_l4("Entering...\n");

       if (cache == NULL)
       {
               persistent_connection_mutex = cg_mutex_new();

               if (persistent_connection_mutex == NULL)
               {
                       return FALSE;
               }

               cg_http_persistentconnection_lock();
               cache = (CgHttpPersistentConnectionList *)malloc(sizeof(CgHttpPersistentConnectionList));

               if (cache == NULL)
               {
                       if (persistent_connection_mutex != NULL)
                       {
                               cg_http_persistentconnection_unlock();
                               cg_mutex_delete(persistent_connection_mutex);
                               persistent_connection_mutex = NULL;
                       }
                       return FALSE;
               }

               cg_list_header_init((CgList *)cache);

               cache->host = NULL;
               cache->port = 0;
               cache->cacheData = NULL;

               cache->timestamp = 0;

               cg_http_persistentconnection_unlock();
       }

       return TRUE;

	cg_log_debug_l4("Leaving...\n");
}
CgFileList *cg_filelist_new()
{
    CgFileList *fileList;

    cg_log_debug_l4("Entering...\n");

    fileList = (CgFileList *)malloc(sizeof(CgFileList));

    if ( NULL != fileList )
    {
        cg_list_header_init((CgList *)fileList);
        fileList->name = NULL;
        fileList->path = NULL;
        fileList->content = NULL;
    }

    cg_log_debug_l4("Leaving...\n");

    return fileList;
}
CgUpnpSSDPResponseServerList *cg_upnp_ssdpresponse_serverlist_new()
{
	CgUpnpSSDPResponseServerList *ssdpServerList;

	cg_log_debug_l4("Entering...\n");

	ssdpServerList = (CgUpnpSSDPResponseServerList *)malloc(sizeof(CgUpnpSSDPResponseServerList));

	if  ( NULL != ssdpServerList )
	{
		cg_list_header_init((CgList *)ssdpServerList);
		
		ssdpServerList->httpuSock = NULL;
		ssdpServerList->recvThread = NULL;
		ssdpServerList->listener = NULL;
	}
	
	return ssdpServerList;

	cg_log_debug_l4("Leaving...\n");
}
CgHttpServerList *cg_http_serverlist_new()
{
	CgHttpServerList *httpServerList;

	cg_log_debug_l4("Entering...\n");

	httpServerList = (CgHttpServerList *)malloc(sizeof(CgHttpServerList));

	if ( NULL != httpServerList )
	{
		cg_list_header_init((CgList *)httpServerList);
		
		httpServerList->sock = NULL;
		httpServerList->acceptThread = NULL;
		httpServerList->listener = NULL;
		httpServerList->userData = NULL;
		httpServerList->mutex = NULL;
	}
	
	cg_log_debug_l4("Leaving...\n");

	return httpServerList;
}