示例#1
0
文件: suffix.c 项目: taysom/tau
int main(int argc, char *argv[]) {
	for (Test *t = test; t->string; t++) {
		const char *suffix = Suffix(t->string);
		if (t->suffix == NULL) {
			aver(suffix == NULL);
		} else {
			aver(suffix != NULL);
			aver(strcmp(suffix, t->suffix) == 0);
		}
	}
	return 0;
}
//-----------------------------------------------------------------------------
// Add to the list!
//-----------------------------------------------------------------------------
void CValidateAlloc::AddToList( HeapPrefix_t *pHeap, int nSize )
{
	pHeap->m_pPrev = NULL;
	pHeap->m_pNext = m_pFirstAllocation;
	if ( m_pFirstAllocation )
	{
		m_pFirstAllocation->m_pPrev = pHeap;
	}
	pHeap->m_nSize = nSize;

	m_pFirstAllocation = pHeap;

	HeapSuffix_t *pSuffix = Suffix( pHeap );
	memcpy( pHeap->m_Prefix, m_pPrefixImage, HEAP_PREFIX_BUFFER_SIZE );
	memcpy( pSuffix->m_Suffix, m_pSuffixImage, HEAP_SUFFIX_BUFFER_SIZE );
}
示例#3
0
	GEN::Pointer<Texture> TextureManager::Get(const std::string& filename, FS::Loader& loader) {
		texIt_t texIt = _textures.find(filename);
		if(_textures.end() == texIt) {
			std::string suffix = ToLower(Suffix(filename));
			allocIt_t allocIt = _allocs.find(suffix);
			if(_allocs.end() == allocIt) {
                common.printf("TextureManager::Get: for suffix '%s' of filename '%s' is no allocator registered.\n",
                    suffix.c_str(), filename.c_str());
				throw std::exception();
			}

			GEN::Pointer<FS::File> file = loader.GetFile(filename);
			GEN::Pointer<Texture> texture(allocIt->second(file));
			_textures[filename] = texture;

			return texture;
		} else {
			return texIt->second;
		}
	}
示例#4
0
	GEN::Pointer<Texture> TextureManager::Get(const std::string& filename, FS::Loader& loader) {
		texIt_t texIt = _textures.find(filename);
		if(_textures.end() == texIt) {
			std::string suffix = ToLower(Suffix(filename));
			allocIt_t allocIt = _allocs.find(suffix);
			if(_allocs.end() == allocIt) {
				COM::log << "TextureManager::Get: for suffix '" << suffix << "' of filename " << filename
					<< " is no allocator registered" << std::endl;
				throw std::exception();
			}

			GEN::Pointer<FS::File> file = loader.GetFile(filename);
			GEN::Pointer<Texture> texture(allocIt->second(file));
			_textures[filename] = texture;

			return texture;
		} else {
			return texIt->second;
		}
	}
//-----------------------------------------------------------------------------
// Validate the allocation
//-----------------------------------------------------------------------------
bool CValidateAlloc::ValidateAllocation( HeapPrefix_t *pHeap )
{
	HeapSuffix_t *pSuffix = Suffix( pHeap );

	bool bOk = true;
	if ( memcmp( pHeap->m_Prefix, m_pPrefixImage, HEAP_PREFIX_BUFFER_SIZE ) )
	{
		bOk = false;
	}

	if ( memcmp( pSuffix->m_Suffix, m_pSuffixImage, HEAP_SUFFIX_BUFFER_SIZE ) )
	{
		bOk = false;
	}

	if ( !bOk )
	{
		Warning("Memory trash detected in allocation %X!\n", (void*)(pHeap+1) );
		Assert( 0 );
	}

	return bOk;
}
 std::string GetAbsolutePath()
 {
   return GetLibraryPath() + "/" + Prefix() + m_Name + Suffix();
 }
 std::string GetAbsolutePath(const std::string& name)
 {
   return GetLibraryPath() + "/" + Prefix() + name + Suffix();
 }
示例#8
0
std::string SharedLibraryHandle::GetAbsolutePath()
{
  return GetLibraryPath() + "/" + Prefix() + m_Name + Suffix();
}
示例#9
0
std::string SharedLibraryHandle::GetAbsolutePath(const std::string& name)
{
  return GetLibraryPath() + "/" + Prefix() + name + Suffix();
}