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


C++ GetBlockSize函数代码示例

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


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


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