当前位置: 首页>>代码示例>>C++>>正文


C++ DataChunk::GetByteSize方法代码示例

本文整理汇总了C++中DataChunk::GetByteSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DataChunk::GetByteSize方法的具体用法?C++ DataChunk::GetByteSize怎么用?C++ DataChunk::GetByteSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataChunk的用法示例。


在下文中一共展示了DataChunk::GetByteSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Allocate

void DataContainer::Allocate() {

	// Check that memory has not been allocated
	if (m_pAllocatedMemory != NULL) {
		_EXCEPTIONT("Attempting Allocate() on attached DataContainer");
	}

	// Allocate memory as one contiguous chunk
	size_t sTotalByteSize = GetTotalByteSize();

	m_pAllocatedMemory =
		reinterpret_cast<unsigned char*>(malloc(sTotalByteSize));

	if (m_pAllocatedMemory == NULL) {
		_EXCEPTIONT("Out of memory");
	}

	// Initialize allocated memory to zero
	memset(m_pAllocatedMemory, 0, sTotalByteSize);

	// Assign memory to DataChunks
	unsigned char * pAccumulated = m_pAllocatedMemory;

	for (size_t i = 0; i < m_vecDataChunks.size(); i++) {
		DataChunk * pDataChunk =
			reinterpret_cast<DataChunk*>(m_vecDataChunks[i]);

		pDataChunk->AttachToData(
			reinterpret_cast<void *>(pAccumulated));

#pragma message "Alignment may be an issue here on 32-bit systems"
		pAccumulated += pDataChunk->GetByteSize();
	}
}
开发者ID:brycelelbach,项目名称:tempestmodel,代码行数:34,代码来源:DataContainer.cpp

示例2: GetTotalByteSize

size_t DataContainer::GetTotalByteSize() const {
	
	// Get the accumulated size of all DataChunks
	size_t sAccumulated = 0;

	for (size_t i = 0; i < m_vecDataChunks.size(); i++) {
		DataChunk * pDataChunk =
			reinterpret_cast<DataChunk*>(m_vecDataChunks[i]);

		// Verify byte alignment
		size_t sByteSize = pDataChunk->GetByteSize();
		if (sByteSize % sizeof(size_t) != 0) {
			_EXCEPTIONT("Misaligned array detected in DataContainer");
		}
		sAccumulated += sByteSize;
	}

	return sAccumulated;
}
开发者ID:brycelelbach,项目名称:tempestmodel,代码行数:19,代码来源:DataContainer.cpp

示例3: AttachTo

void DataContainer::AttachTo(
	unsigned char * pAllocatedMemory
) {
	if (m_pAllocatedMemory != NULL) {
		_EXCEPTIONT("Attempting AttachTo() on attached DataContainer");
	}

	m_fOwnsData = false;
	m_pAllocatedMemory = pAllocatedMemory;

	// Assign memory to DataChunks
	unsigned char * pAccumulated = m_pAllocatedMemory;

	for (size_t i = 0; i < m_vecDataChunks.size(); i++) {

		DataChunk * pDataChunk =
			reinterpret_cast<DataChunk *>(m_vecDataChunks[i]);
		pDataChunk->AttachToData(
			reinterpret_cast<void *>(pAccumulated));

		pAccumulated += pDataChunk->GetByteSize();
	}
}
开发者ID:brycelelbach,项目名称:tempestmodel,代码行数:23,代码来源:DataContainer.cpp


注:本文中的DataChunk::GetByteSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。