Example #1
0
DeviceOpener::~DeviceOpener()
{
	if (fDevice >= 0) {
		RemoveCache(false);
		close(fDevice);
	}
}
Example #2
0
int ResetDNSCache(){
	int	iTemp;
	if (sDNSCache){
		for (iTemp = 0; iTemp < iDNSCacheCount; iTemp++){
			RemoveCache(iTemp, 0);
		}
		delete [] sDNSCache;
		sDNSCache = 0;
	}
	return 1;
}
Example #3
0
sDNS *AddDNSCache(char *szName, char *szIP){
	int	iEntry;

	if (!szName && !szIP){
		return 0;
	}
	if (iDNSCacheCount < iDNSCacheLimit){
		sDNS	**sTemp;
		sDNS	*sNewDNS;

		iEntry = iDNSCacheCount;
		if (sNewDNS = new sDNS){
			sNewDNS->szIP = 0;
			sNewDNS->szName = 0;
			sNewDNS->lLastUse = 0;
		
				//	Allocate room for the array and move it over
			if (sTemp = new sDNS* [iDNSCacheCount + 1]){
				if (sDNSCache){
					memcpy(sTemp, sDNSCache, sizeof(sDNS*) * iDNSCacheCount);
					delete [] sDNSCache;
				}
				sDNSCache = sTemp;
				sTemp = 0;
				sDNSCache[iDNSCacheCount] = sNewDNS;
				iDNSCacheCount++;
			}
		}else{
			return 0;
		}
	}else{
		int	iTemp;
		if (! sDNSCache){
			return 0;
		}

		iEntry = 0;
			//	Let's find the oldest cache entry and replace it
		for (iTemp = 0; iTemp < iDNSCacheLimit; iTemp++){
			if (sDNSCache[iTemp]->lLastUse < sDNSCache[iEntry]->lLastUse){
				iEntry = iTemp;
			}
		}
			//	Since we are going to simply replace the entry we will not force
			//	the reallocation of the list's memory.
		RemoveCache(iEntry, 0);
			//	Now we must allocate a new DNS memory block.
		if (sDNSCache[iEntry] = new sDNS){
			sDNSCache[iEntry]->szIP = 0;
			sDNSCache[iEntry]->szName = 0;
		}else{
			return 0;
		}
	}
	if (!sDNSCache[iEntry]){
		return 0;
	}
	sDNSCache[iEntry]->szIP = DupString(szIP);
	sDNSCache[iEntry]->szName = DupString(szName);
	if (!szName){
		sDNSCache[iEntry]->szName = 0;
	}
	if (!szIP){
		sDNSCache[iEntry]->szIP = 0;
	}
	sDNSCache[iEntry]->lLastUse = lDNSCacheTime++;
	return sDNSCache[iEntry];
}	
Example #4
0
 void Text::SetColor(const SDL_Color& color)
 {
   _color = color;
   RemoveCache();
 }
Example #5
0
 void Text::SetTextAndColor(const std::string& text, const SDL_Color& color)
 {
   _color = color;
   _text = text;
   RemoveCache();
 }
Example #6
0
 void Text::SetText(const std::string& text)
 {
   _text = text;
   RemoveCache();
 }