• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetBlockSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetBlockSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GetBlockSize函数的具体用法?C++ GetBlockSize怎么用?C++ GetBlockSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: FFC_MountImage

/**
 * @public
 * @brief	Mounts and Image with FullFAT.
 *
 *
 **/
DLL_EXPORT int FFC_MountImage(char *szFilename, unsigned long ulBlockSize, unsigned long ulPartitionNumber) {

	FF_ERROR Error = FF_ERR_NONE;

	if(g_pIoman || g_hDisk) {
		return FFD_ERR_IMAGE_ALREADY_MOUNTED;
	}

	g_hDisk = fnOpen(szFilename, ulBlockSize);

	if(!g_hDisk) {
		return FFD_ERR_COULD_NOT_OPEN_IMAGE;
	}
	
	g_pIoman = FF_CreateIOMAN(NULL, 8192, GetBlockSize(g_hDisk), &Error);	// Using the BlockSize from the Device Driver (see blkdev_win32.c)

	if(!g_pIoman) {
		return FFD_ERR_COULD_NOT_INITIALISE_FULLFAT;
	} else {
		Error = FF_RegisterBlkDevice(g_pIoman, GetBlockSize(g_hDisk), (FF_WRITE_BLOCKS) fnWrite, (FF_READ_BLOCKS) fnRead, g_hDisk);

		if(Error) {
			printError(Error);

			FF_DestroyIOMAN(g_pIoman);
			fnClose(g_hDisk);

			return -1;
		}

		// Attempt to mount!

		Error = FF_MountPartition(g_pIoman, (FF_T_UINT8) ulPartitionNumber);
		if(Error) {
			if(g_hDisk) {
				fnClose(g_hDisk);
			}
			FF_DestroyIOMAN(g_pIoman);
			g_pIoman = NULL;
			return -1;
		}

		g_Env.pIoman = g_pIoman;
		strcpy(g_Env.WorkingDir, "\\");	// Reset working dir!
	}

	return FFD_ERR_NONE;
}
开发者ID:jgottula,项目名称:automaton,代码行数:54,代码来源:FullFAT32.dll.c


示例2: GetBlockSize

void GDALRasterBlock::Detach_unlocked()
{
    if( poOldest == this )
        poOldest = poPrevious;

    if( poNewest == this )
    {
        poNewest = poNext;
    }

    if( poPrevious != NULL )
        poPrevious->poNext = poNext;

    if( poNext != NULL )
        poNext->poPrevious = poPrevious;

    poPrevious = NULL;
    poNext = NULL;
    bMustDetach = FALSE;

    if( pData )
        nCacheUsed -= GetBlockSize();

#ifdef ENABLE_DEBUG
    Verify();
#endif
}
开发者ID:miccferr,项目名称:wmshp-electron,代码行数:27,代码来源:gdalrasterblock.cpp


示例3: ASSERT

void CItemField::Get(unsigned char *value, size_t &length, Fish *bf) const
{
  // Sanity check: length is 0 iff data ptr is NULL
  ASSERT((m_Length == 0 && m_Data == NULL) ||
         (m_Length > 0 && m_Data != NULL));
  /*
  * length is an in/out parameter:
  * In: size of value array - must be at least BlockLength
  * Out: size of data stored: m_Length (No trailing zero!)
  * if In < BlockLength, assertion is triggered (no way to handle gracefully)
  */
  if (m_Length == 0) {
    value[0] = TCHAR('\0');
    length = 0;
  } else { // we have data to decrypt
    size_t BlockLength = GetBlockSize(m_Length);
    ASSERT(length >= BlockLength);
    unsigned char *tempmem = new unsigned char[BlockLength];

    size_t x;
    for (x = 0; x < BlockLength; x += 8)
      bf->Decrypt(m_Data + x, tempmem + x);

    for (x = 0; x < BlockLength; x++)
      value[x] = (x < m_Length) ? tempmem[x] : 0;

    length = m_Length;
    delete [] tempmem;
  }
}
开发者ID:macduff,项目名称:passwordsafe,代码行数:30,代码来源:ItemField.cpp


示例4: transfer

// Writes data to a file (asynchronous overload).
AKRESULT CAkDefaultIOHookDeferred::Write(
	AkFileDesc &			in_fileDesc,        // File descriptor.
	const AkIoHeuristics & /*in_heuristics*/,	// Heuristics for this data transfer (not used in this implementation).
	AkAsyncIOTransferInfo & io_transferInfo		// Platform-specific asynchronous IO operation info.
	)
{
	AKASSERT( in_fileDesc.hFile != INVALID_HANDLE_VALUE 
			&& io_transferInfo.uRequestedSize > 0 );

	// If this assert comes up, it might be beacause this hook's GetBlockSize() return value is incompatible 
	// with the system's handling of file reading for this specific file handle.
	// Are you using the File Package Low-Level I/O with incompatible block size? (check -blocksize argument in the File Packager command line)
	AKASSERT( io_transferInfo.uFilePosition % GetBlockSize( in_fileDesc ) == 0
			|| !"Requested file position for I/O transfer is inconsistent with block size" );

	OVERLAPPED * pOverlapped = GetFreeOverlapped( &io_transferInfo );
	
	// Set file offset in OVERLAPPED structure.
	pOverlapped->Offset = (DWORD)( io_transferInfo.uFilePosition & 0xFFFFFFFF );
	pOverlapped->OffsetHigh = (DWORD)( ( io_transferInfo.uFilePosition >> 32 ) & 0xFFFFFFFF );

    // File was open with asynchronous flag. 
    // Read overlapped. 
    if ( ::WriteFileEx( in_fileDesc.hFile,
                      io_transferInfo.pBuffer,
                      io_transferInfo.uRequestedSize,
                      pOverlapped,
					  CAkDefaultIOHookDeferred::FileIOCompletionRoutine ) )
	{
		return AK_Success;
	}
	ReleaseOverlapped( pOverlapped );
    return AK_Fail;
}
开发者ID:Psybrus,项目名称:Psybrus,代码行数:35,代码来源:AkDefaultIOHookDeferred.cpp


示例5: GetAllocSize

int32_t FixedMemPool::Init(void* mem, uint32_t max_node_num, size_t node_size, bool check_header) {
    if (!mem) {
        return -1;
    }

    m_header = (MemHeader*)mem;

    if (!check_header) {
        //init head
        m_header->max_size = GetAllocSize(max_node_num, node_size);
        m_header->max_node_num = max_node_num;
        //we use the beginning of the memory pool to as head infomation
        m_header->used_size = sizeof(MemHeader);
        m_header->used_node_num = 0;
        //block size is based on node size aligned by 8 bytes
        m_header->block_size = GetBlockSize(node_size);
        //no block is freed
        m_header->free_list_offset = kInvalidPointer;

        m_data = (char*)m_header + sizeof(MemHeader);
    } else {
        if (!CheckHeader(max_node_num, node_size, m_header)) {
            snprintf(m_error_msg, sizeof(m_error_msg), "Memory pool head check error!");
            return -1;
        }

        m_data = (char*)m_header + sizeof(MemHeader);
    }

    return 0;
}
开发者ID:sunwaylive,项目名称:caribean-fight-server,代码行数:31,代码来源:fixed_mem_pool.cpp


示例6: GetFromFreelist

static TRI_hash_index_element_multi_t* GetFromFreelist (TRI_hash_array_multi_t* array) {
  if (array->_freelist == nullptr) {
    size_t blockSize = GetBlockSize(array->_blocks._length);
    TRI_ASSERT(blockSize > 0);

    auto begin = static_cast<TRI_hash_index_element_multi_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, blockSize * OverflowEntrySize(), true));

    if (begin == nullptr) {
      return nullptr;
    }

    auto ptr = begin;
    auto end = begin + (blockSize - 1);

    while (ptr < end) {
      ptr->_next = (ptr + 1);
      ++ptr;
    }

    array->_freelist = begin;
    TRI_PushBackVectorPointer(&array->_blocks, begin);

    array->_nrOverflowAlloc += blockSize;
  }

  auto next = array->_freelist;
  TRI_ASSERT(next != nullptr);
  array->_freelist = next->_next;
  array->_nrOverflowUsed++;
   
  return next;
}
开发者ID:cloud-coders,项目名称:arangodb,代码行数:32,代码来源:hash-array-multi.cpp


示例7: GetBlockSize

int CryptoStreamEncryptionCBC::CalculateEncryptedTargetLength(int source_length) const
{
	int block_size = GetBlockSize();

	switch (m_padding_strategy)
	{
	case PADDING_STRATEGY_NONE:
		OP_ASSERT(source_length % block_size == 0);
		return source_length;

	case PADDING_STRATEGY_PCKS15:
		/*
		 * Pad the encrypted target with byte 'n' where n is the number
		 * of padding bytes. Bytes are added until target_length == 0 mod
		 * block_size
		 *
		 * If source length  == 0 mod block size, one block of padding
		 * is added.
		 */
		return source_length + (block_size - (source_length % block_size));

	default:
		OP_ASSERT(!"UNKNOWN PADDING STRATEGY");
		return source_length;
	}
}
开发者ID:prestocore,项目名称:browser,代码行数:26,代码来源:CryptoStreamEncryptionCBC.cpp


示例8: OP_ASSERT

void CryptoStreamEncryptionCBC::Encrypt(const UINT8 *source, UINT8 *target, int source_length, int target_length)
{
	// IMPROVE ME : Implement cipher stealing for arbitrary lengths

	OP_ASSERT(source && target && source_length >= 0 && target_length >= 0);

	if (target_length == 0 && m_padding_strategy == PADDING_STRATEGY_NONE)
		target_length = source_length;

	OP_ASSERT(target_length == CalculateEncryptedTargetLength(source_length));
	UINT8 padding_byte = target_length - source_length;

	m_algorithm->SetEncryptKey(m_key);

	int block_size = GetBlockSize();

	for (int i = 0; i < target_length; i++)
	{
		UINT8 source_byte = i < source_length ? source[i] : padding_byte;

		m_state[m_state_counter] = m_state[m_state_counter] ^ source_byte;

		m_state_counter = (m_state_counter + 1) % block_size;

		if (!m_state_counter)
		{
			m_algorithm->Encrypt(m_state, target + i + 1 - block_size);
			op_memmove(m_state, target + i + 1 - block_size, block_size);
		}
	}
}
开发者ID:prestocore,项目名称:browser,代码行数:31,代码来源:CryptoStreamEncryptionCBC.cpp


示例9: GetPitch

void CBaseTexture::ClampToEdge()
{
  unsigned int imagePitch = GetPitch(m_imageWidth);
  unsigned int imageRows = GetRows(m_imageHeight);
  unsigned int texturePitch = GetPitch(m_textureWidth);
  unsigned int textureRows = GetRows(m_textureHeight);
  if (imagePitch < texturePitch)
  {
    unsigned int blockSize = GetBlockSize();
    unsigned char *src = m_pixels + imagePitch - blockSize;
    unsigned char *dst = m_pixels;
    for (unsigned int y = 0; y < imageRows; y++)
    {
      for (unsigned int x = imagePitch; x < texturePitch; x += blockSize)
        memcpy(dst + x, src, blockSize);
      dst += texturePitch;
    }
  }

  if (imageRows < textureRows)
  {
    unsigned char *dst = m_pixels + imageRows * texturePitch;
    for (unsigned int y = imageRows; y < textureRows; y++)
    {
      memcpy(dst, dst - texturePitch, texturePitch);
      dst += texturePitch;
    }
  }
}
开发者ID:AWilco,项目名称:xbmc,代码行数:29,代码来源:Texture.cpp


示例10: while

void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned int format)
{
  m_imageWidth = width;
  m_imageHeight = height;
  m_format = format;
  m_orientation = 0;

  m_textureWidth = m_imageWidth;
  m_textureHeight = m_imageHeight;

  if (m_format & XB_FMT_DXT_MASK)
    while (GetPitch() < g_Windowing.GetMinDXTPitch())
      m_textureWidth += GetBlockSize();

  if (!g_Windowing.SupportsNPOT((m_format & XB_FMT_DXT_MASK) != 0))
  {
    m_textureWidth = PadPow2(m_textureWidth);
    m_textureHeight = PadPow2(m_textureHeight);
  }
  if (m_format & XB_FMT_DXT_MASK)
  { // DXT textures must be a multiple of 4 in width and height
    m_textureWidth = ((m_textureWidth + 3) / 4) * 4;
    m_textureHeight = ((m_textureHeight + 3) / 4) * 4;
  }

  // check for max texture size
  #define CLAMP(x, y) { if (x > y) x = y; }
  CLAMP(m_textureWidth, g_Windowing.GetMaxTextureSize());
  CLAMP(m_textureHeight, g_Windowing.GetMaxTextureSize());
  CLAMP(m_imageWidth, m_textureWidth);
  CLAMP(m_imageHeight, m_textureHeight);

  delete[] m_pixels;
  m_pixels = new unsigned char[GetPitch() * GetRows()];
}
开发者ID:AWilco,项目名称:xbmc,代码行数:35,代码来源:Texture.cpp


示例11: decltype

bool Engine<routing_algorithms::corech::Algorithm>::CheckCompability(const EngineConfig &config)
{
    if (!Engine<routing_algorithms::ch::Algorithm>::CheckCompability(config))
    {
        return false;
    }

    if (config.use_shared_memory)
    {
        storage::SharedMonitor<storage::SharedDataTimestamp> barrier;
        using mutex_type = typename decltype(barrier)::mutex_type;
        boost::interprocess::scoped_lock<mutex_type> current_region_lock(barrier.get_mutex());

        auto mem = storage::makeSharedMemory(barrier.data().region);
        auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr());
        return layout->GetBlockSize(storage::DataLayout::CH_CORE_MARKER_0) >
               sizeof(std::uint64_t) + sizeof(util::FingerPrint);
    }
    else
    {
        if (!boost::filesystem::exists(config.storage_config.GetPath(".osrm.core")))
            return false;
        storage::io::FileReader in(config.storage_config.GetPath(".osrm.core"),
                                   storage::io::FileReader::VerifyFingerprint);
        in.ReadElementCount64(); // number of core markers
        const auto number_of_core_markers = in.ReadElementCount64();

        return number_of_core_markers > 0;
    }
}
开发者ID:frodrigo,项目名称:osrm-backend,代码行数:30,代码来源:engine.hpp


示例12: Compress_RG

  void Compress_RG(const FasTC::CompressionJob &cj) {

    rg_etc1::etc1_pack_params params;
    params.m_quality = rg_etc1::cLowQuality;
    rg_etc1::pack_etc1_block_init();

    uint32 kBlockSz = GetBlockSize(FasTC::eCompressionFormat_ETC1);
    const uint32 startBlock = cj.CoordsToBlockIdx(cj.XStart(), cj.YStart());
    uint8 *outBuf = cj.OutBuf() + startBlock * kBlockSz;

    const uint32 endY = std::min(cj.YEnd(), cj.Height() - 4);
    uint32 startX = cj.XStart();
    for(uint32 j = cj.YStart(); j <= endY; j += 4) {
      const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width();
      for(uint32 i = startX; i < endX; i += 4) {

        uint32 pixels[16];
        const uint32 *inPixels = reinterpret_cast<const uint32 *>(cj.InBuf());
        memcpy(pixels, inPixels + j*cj.Width() + i, 4 * sizeof(uint32));
        memcpy(pixels + 4, inPixels + (j+1)*cj.Width() + i, 4 * sizeof(uint32));
        memcpy(pixels + 8, inPixels + (j+2)*cj.Width() + i, 4 * sizeof(uint32));
        memcpy(pixels + 12, inPixels + (j+3)*cj.Width() + i, 4 * sizeof(uint32));

        pack_etc1_block(outBuf, pixels, params);
        outBuf += kBlockSz;
      }
      startX = 0;
    }
  }
开发者ID:Nuos,项目名称:FasTC,代码行数:29,代码来源:Compressor.cpp


示例13: ReadBlocks

bool FileBlockDevice::ReadBlocks(u32 minBlock, int count, u8 *outPtr) {
	if (fileLoader_->ReadAt((u64)minBlock * (u64)GetBlockSize(), 2048, count, outPtr) != (size_t)count) {
		ERROR_LOG(FILESYS, "Could not read %d bytes from block", 2048 * count);
		return false;
	}
	return true;
}
开发者ID:Frankie-666,项目名称:ppsspp,代码行数:7,代码来源:BlockDevices.cpp


示例14: while

void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned int format)
{
  m_imageWidth = m_originalWidth = width;
  m_imageHeight = m_originalHeight = height;
  m_format = format;
  m_orientation = 0;

  m_textureWidth = m_imageWidth;
  m_textureHeight = m_imageHeight;

  if (m_format & XB_FMT_DXT_MASK)
    while (GetPitch() < CServiceBroker::GetRenderSystem().GetMinDXTPitch())
      m_textureWidth += GetBlockSize();

  if (!CServiceBroker::GetRenderSystem().SupportsNPOT((m_format & XB_FMT_DXT_MASK) != 0))
  {
    m_textureWidth = PadPow2(m_textureWidth);
    m_textureHeight = PadPow2(m_textureHeight);
  }
  if (m_format & XB_FMT_DXT_MASK)
  { // DXT textures must be a multiple of 4 in width and height
    m_textureWidth = ((m_textureWidth + 3) / 4) * 4;
    m_textureHeight = ((m_textureHeight + 3) / 4) * 4;
  }
  else
  {
    // align all textures so that they have an even width
    // in some circumstances when we downsize a thumbnail
    // which has an uneven number of pixels in width
    // we crash in CPicture::ScaleImage in ffmpegs swscale
    // because it tries to access beyond the source memory
    // (happens on osx and ios)
    // UPDATE: don't just update to be on an even width;
    // ffmpegs swscale relies on a 16-byte stride on some systems
    // so the textureWidth needs to be a multiple of 16. see ffmpeg
    // swscale headers for more info.
    m_textureWidth = ((m_textureWidth + 15) / 16) * 16;
  }

  // check for max texture size
  #define CLAMP(x, y) { if (x > y) x = y; }
  CLAMP(m_textureWidth, CServiceBroker::GetRenderSystem().GetMaxTextureSize());
  CLAMP(m_textureHeight, CServiceBroker::GetRenderSystem().GetMaxTextureSize());
  CLAMP(m_imageWidth, m_textureWidth);
  CLAMP(m_imageHeight, m_textureHeight);

  _aligned_free(m_pixels);
  m_pixels = NULL;
  if (GetPitch() * GetRows() > 0)
  {
    size_t size = GetPitch() * GetRows();
    m_pixels = (unsigned char*) _aligned_malloc(size, 32);

    if (m_pixels == nullptr)
    {
      CLog::Log(LOGERROR, "%s - Could not allocate %zu bytes. Out of memory.", __FUNCTION__, size);
    }
  }
}
开发者ID:Montellese,项目名称:xbmc,代码行数:59,代码来源:Texture.cpp


示例15: GetBlockSize

bool RAMBlockDevice::ReadBlock(int blockNumber, u8 *outPtr) {
	if (blockNumber >= 0 && blockNumber < totalBlocks_) {
		u32 blockSize = GetBlockSize();
		memcpy(outPtr, image_ + blockSize * blockNumber, blockSize);
		return true;
	}
	return false;
}
开发者ID:BBCbbb,项目名称:ppsspp,代码行数:8,代码来源:BlockDevices.cpp


示例16: ReadBlock

bool FileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr) {
	if (fileLoader_->ReadAt((u64)blockNumber * (u64)GetBlockSize(), 1, 2048, outPtr) != 2048) {
		DEBUG_LOG(FILESYS, "Could not read 2048 bytes from block");
		return false;
	}

	return true;
}
开发者ID:BBCbbb,项目名称:ppsspp,代码行数:8,代码来源:BlockDevices.cpp


示例17: fseek

bool FileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr) 
{
	fseek(f, blockNumber * GetBlockSize(), SEEK_SET);
	if(fread(outPtr, 1, 2048, f) != 2048)
		DEBUG_LOG(LOADER, "Could not read 2048 bytes from block");

	return true;
}
开发者ID:173210,项目名称:ppsspp,代码行数:8,代码来源:BlockDevices.cpp


示例18: Assert

// Size of committed memory managed by this heap:
int CSmallBlockPool::GetCommittedSize()
{
	unsigned totalSize = (unsigned)m_pCommitLimit - (unsigned)m_pBase;
	Assert( 0 != m_nBlockSize );
	Assert( 0 != ( totalSize % GetBlockSize() ) );

	return totalSize;
}
开发者ID:hzqst,项目名称:CaptionMod,代码行数:9,代码来源:memstd.cpp


示例19: lock

void RaspberryJammer::Reset()
{
  TRACE;
  IMutexLock lock(this);

  this->synth.Reset();
  this->synth.SetSampleRate(GetSampleRate());
  mMidiQueue.Resize(GetBlockSize());
}
开发者ID:benwad,项目名称:RaspberryJamPlugin,代码行数:9,代码来源:RaspberryJammer.cpp


示例20: ReadBlock

bool FileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr, bool uncached) {
	FileLoader::Flags flags = uncached ? FileLoader::Flags::HINT_UNCACHED : FileLoader::Flags::NONE;
	if (fileLoader_->ReadAt((u64)blockNumber * (u64)GetBlockSize(), 1, 2048, outPtr, flags) != 2048) {
		DEBUG_LOG(FILESYS, "Could not read 2048 bytes from block");
		return false;
	}

	return true;
}
开发者ID:Frankie-666,项目名称:ppsspp,代码行数:9,代码来源:BlockDevices.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetBlueprint函数代码示例发布时间:2022-05-30
下一篇:
C++ GetBlobSize函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap