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


C++ AllocMemory函数代码示例

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


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

示例1: slConsole

// Initialize the console.
void CConsole::Initialize(const CTFileName &fnmLog, INDEX ctCharsPerLine, INDEX ctLines)
{
  con_csConsole.cs_iIndex = -1;
  // synchronize access to console
  CTSingleLock slConsole(&con_csConsole, TRUE);

  // allocate the buffer
  con_ctCharsPerLine = ctCharsPerLine;
  con_ctLines        = ctLines;
  con_ctLinesPrinted = 0;
  // note: we add +1 for '\n' perline and +1 '\0' at the end of buffer
  con_strBuffer = (char *)AllocMemory((ctCharsPerLine+2)*ctLines+1);
  con_strLineBuffer = (char *)AllocMemory(ctCharsPerLine+2); // includes '\n' and '\0'
  con_atmLines = (TIME*)AllocMemory((ctLines+1)*sizeof(TIME));
  // make it empty
  for(INDEX iLine=0; iLine<ctLines; iLine++) {
    ClearLine(iLine);
  }
  // add string terminator at the end
  con_strBuffer[(ctCharsPerLine+1)*ctLines] = 0;

  // start printing in last line
  con_strLastLine = con_strBuffer+(ctCharsPerLine+1)*(ctLines-1);
  con_strCurrent = con_strLastLine;

//안태훈 수정 시작	//(Block Log)(0.1)
  //CreateLogFile(fnmLog);	//로그파일 생성을 막는다.
//안태훈 수정 끝	//(Block Log)(0.1)

  // print one dummy line on start
  CPrintF("\n");
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:33,代码来源:Console.cpp

示例2: AACQuantizeInit

void AACQuantizeInit(CoderInfo *coderInfo, unsigned int numChannels,
		     AACQuantCfg *aacquantCfg)
{
    unsigned int channel, i;

    aacquantCfg->pow43 = (double*)AllocMemory(PRECALC_SIZE*sizeof(double));
    aacquantCfg->adj43 = (double*)AllocMemory(PRECALC_SIZE*sizeof(double));

    aacquantCfg->pow43[0] = 0.0;
    for(i=1;i<PRECALC_SIZE;i++)
        aacquantCfg->pow43[i] = pow((double)i, 4.0/3.0);

#if TAKEHIRO_IEEE754_HACK
    aacquantCfg->adj43[0] = 0.0;
    for (i = 1; i < PRECALC_SIZE; i++)
      aacquantCfg->adj43[i] = i - 0.5 - pow(0.5 * (aacquantCfg->pow43[i - 1] + aacquantCfg->pow43[i]),0.75);
#else // !TAKEHIRO_IEEE754_HACK
    for (i = 0; i < PRECALC_SIZE-1; i++)
        aacquantCfg->adj43[i] = (i + 1) - pow(0.5 * (aacquantCfg->pow43[i] + aacquantCfg->pow43[i + 1]), 0.75);
    aacquantCfg->adj43[i] = 0.5;
#endif

    for (channel = 0; channel < numChannels; channel++) {
        coderInfo[channel].requantFreq = (double*)AllocMemory(BLOCK_LEN_LONG*sizeof(double));
    }
}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:26,代码来源:aacquant.c

示例3: AllocMemory

char *GetCurrentWorkingDirectory (void)
{
	long buffer_length = 128;
	char *buffer_s = (char *) AllocMemory (buffer_length);
	char *path_s = NULL;

	while (!path_s && buffer_s)
		{
			path_s = getcwd (buffer_s, buffer_length);

			if (!path_s)
				{
					FreeMemory (buffer_s);

					if (errno == ERANGE)
						{
							buffer_length <<= 1;
							buffer_s = (char *) AllocMemory (buffer_length);
						}
					else
						{
							buffer_s = NULL;
						}
				}
		}

	return path_s;
}
开发者ID:TGAC,项目名称:grassroots-api,代码行数:28,代码来源:unix_filesystem.c

示例4: ComputeDTWHammingDistance

void
ComputeDTWHammingDistance(VG_RAM_WNN *vg_ram_wnn, DATA_SET *testing_set, double *accumulated_cost, int *step_list, int step_list_size)
{
	int data_size = vg_ram_wnn->memory_size;
	int query_size = testing_set->num_samples;
	int number_of_neurons = vg_ram_wnn->number_of_neurons;
	int memory_bit_group_size = vg_ram_wnn->memory_bit_group_size;

	int *query = (int *) AllocMemory((size_t) number_of_neurons * query_size * (memory_bit_group_size + 1) * sizeof(int));
	int *neuron_cost = (int *) AllocMemory((size_t) number_of_neurons * data_size * query_size * sizeof(int));
	double *mean_cost = (double *) AllocMemory((size_t) data_size * query_size * sizeof(double));

	BuildBitPatternForQuery(vg_ram_wnn, testing_set, query);

	ComputeLocalCostForNeurons(vg_ram_wnn, query, query_size, neuron_cost);
//	SaveLocalCostMatrix(neuron_cost, number_of_neurons, query_size, data_size);

	ComputeMeanCostForNeurons(neuron_cost, query_size, data_size, number_of_neurons, mean_cost);
//	SaveMeanCostMatrix(mean_cost, query_size, data_size);

	ComputeAccumulatedCost(mean_cost, query_size, data_size, step_list, step_list_size, accumulated_cost);
//	SaveAccumCostMatrix(accumulated_cost, query_size, data_size);

	free(query);
	free(mean_cost);
	free(neuron_cost);
}
开发者ID:LCAD-UFES,项目名称:SABGL,代码行数:27,代码来源:vgram_test_dtw.cpp

示例5: LtpInit

void LtpInit(faacEncStruct* hEncoder)
{
    int i;
    unsigned int channel;

    for (channel = 0; channel < hEncoder->numChannels; channel++) {
        LtpInfo *ltpInfo = &(hEncoder->coderInfo[channel].ltpInfo);

        ltpInfo->buffer = AllocMemory(NOK_LT_BLEN * sizeof(double));
        ltpInfo->mdct_predicted = AllocMemory(2*BLOCK_LEN_LONG*sizeof(double));
        ltpInfo->time_buffer = AllocMemory(BLOCK_LEN_LONG*sizeof(double));
        ltpInfo->ltp_overlap_buffer = AllocMemory(BLOCK_LEN_LONG*sizeof(double));

        for (i = 0; i < NOK_LT_BLEN; i++)
            ltpInfo->buffer[i] = 0;

        ltpInfo->weight_idx = 0;
        for(i = 0; i < MAX_SHORT_WINDOWS; i++)
            ltpInfo->sbk_prediction_used[i] = ltpInfo->delay[i] = 0;

        for(i = 0; i < MAX_SCFAC_BANDS; i++)
            ltpInfo->sfb_prediction_used[i] = 0;

        ltpInfo->side_info = LEN_LTP_DATA_PRESENT;

        for(i = 0; i < 2 * BLOCK_LEN_LONG; i++)
            ltpInfo->mdct_predicted[i] = 0.0;

	}
}
开发者ID:Arcen,项目名称:faac,代码行数:30,代码来源:ltp.c

示例6: DIFF_Diff_t

// make a difference file from two saved games
void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff)
{
  try {
    CTimerValue tv0 = _pTimer->GetHighPrecisionTimer();

    _slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t();
    _pubOld = (UBYTE*)AllocMemory(_slSizeOld);
    pstrmOld->Read_t(_pubOld, _slSizeOld);

    _slSizeNew = pstrmNew->GetStreamSize()-pstrmNew->GetPos_t();
    _pubNew = (UBYTE*)AllocMemory(_slSizeNew);
    pstrmNew->Read_t(_pubNew, _slSizeNew);

    CRC_Start(_ulCRC);
    CRC_AddBlock(_ulCRC, _pubNew, _slSizeNew);
    CRC_Finish(_ulCRC);

    _pstrmOut = pstrmDiff;

    MakeDiff_t();

    CTimerValue tv1 = _pTimer->GetHighPrecisionTimer();
    //CPrintF("diff encoded in %.2gs\n", (tv1-tv0).GetSeconds());

    Cleanup();

  } catch (char *) {
    Cleanup();
    throw;
  }
}
开发者ID:DrItanium,项目名称:Serious-Engine,代码行数:32,代码来源:Diff.cpp

示例7: DIFF_Undiff_t

// make a new saved game from difference file and old saved game
void DIFF_Undiff_t(CTStream *pstrmOld, CTStream *pstrmDiff, CTStream *pstrmNew)
{
  try {
    CTimerValue tv0 = _pTimer->GetHighPrecisionTimer();

    _slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t();
    _pubOld = (UBYTE*)AllocMemory(_slSizeOld);
    pstrmOld->Read_t(_pubOld, _slSizeOld);

    _slSizeNew = pstrmDiff->GetStreamSize()-pstrmDiff->GetPos_t();
    _pubNew = (UBYTE*)AllocMemory(_slSizeNew);
    pstrmDiff->Read_t(_pubNew, _slSizeNew);

    _pstrmOut = pstrmNew;

    UnDiff_t();

    CTimerValue tv1 = _pTimer->GetHighPrecisionTimer();
    //CPrintF("diff decoded in %.2gs\n", (tv1-tv0).GetSeconds());

    Cleanup();

  } catch (char *) {
    Cleanup();
    throw;
  }
}
开发者ID:DrItanium,项目名称:Serious-Engine,代码行数:28,代码来源:Diff.cpp

示例8: while

bool	IndexBitConnector::Load(char *fileName)
{
	IndexBitConnectorHeader	h;
	while (true)
	{
		if (CacheFileName.Set(fileName)==false)
			break;
		if (OpeanCacheFile(fileName,CACHE_SIG_NAME,&h,sizeof(h))==false)
			break;
		if (Data!=NULL)
			delete Data;
		if (Indexes!=NULL)
			delete Indexes;
		Data = NULL;
		Indexes = NULL;
		MemToAlloc = h.MemToAlloc;
		Method = h.Flags; 
	
		if (CacheMemory!=0)
		{
			notifier->Info("[%s] -> Using %d bytes for cache",ObjectName,CacheMemory);
			if (AllocMemory(CacheMemory)==false)
			{
				notifier->Error("[%s] -> Unable to allocate space for cache memory (%d)",ObjectName,CacheMemory);
				break;
			}
			if (file.SetFilePos((UInt64)sizeof(h)+(UInt64)MemToAlloc)==false)
				break;			
		} else {
			if (AllocMemory(h.MemToAlloc)==false)
			{
				notifier->Error("[%s] -> Unable to allocate space for cache initialization",ObjectName);
				break;
			}
			if (file.Read(Data,MemToAlloc)==false)
				break;
		}
		if (file.Read(Indexes,sizeof(UInt64)*((UInt64)nrRecords))==false)
			break;
		if (file.Read(Labels.GetData(),Labels.GetAllocated())==false)
			break;
		if (LoadRecordHashesAndFeatureNames(&h)==false)
			break;
		CloseCacheFile();
		if (CacheMemory!=0)
		{
			dataMemorySize = (UInt64)nrRecords * sizeof(UInt64) + CacheMemory+Labels.GetAllocated();
		} else {
			dataMemorySize = (UInt64)nrRecords * sizeof(UInt64) + MemToAlloc+Labels.GetAllocated();
		}		
		return true;		
	}
	ClearColumnIndexes();
	CloseCacheFile();
	CacheFileName.Set("");
	notifier->Error("[%s] -> Error read data from %s",ObjectName,fileName);
	return false;
}
开发者ID:berendeanicolae,项目名称:gml,代码行数:58,代码来源:IndexBitConnector.cpp

示例9: GenerateFont

static void GenerateFont(void)
{
  if(!_bInitialized) return;
  try {
    _iiFont.Clear();
    _iiGrid.Clear();

    _iiFont.ii_Width = GetIntFromControl(ICB_TEX_WIDTH);
    _iiFont.ii_Height = GetIntFromControl(ICB_TEX_HEIGHT);
    _iiFont.ii_BitsPerPixel = 32;

    _iiGrid.ii_Width = _iiFont.ii_Width;
    _iiGrid.ii_Height = _iiFont.ii_Height;
    _iiGrid.ii_BitsPerPixel = _iiFont.ii_BitsPerPixel;

    SLONG slSize = _iiFont.ii_Width*_iiFont.ii_Height * _iiFont.ii_BitsPerPixel/8;
    _iiFont.ii_Picture = (UBYTE*)AllocMemory(slSize);
    _iiGrid.ii_Picture = (UBYTE*)AllocMemory(slSize);

    memset(_iiFont.ii_Picture,0,slSize);
    memset(_iiGrid.ii_Picture,0,slSize);

    CTString strFontName = GetFontName();
    if(strFontName.Length() == 0) {
      throw("No font selected");
    }


    ULONG ulFlags = GetFontFlags();
    INDEX iFontSize = GetIntFromControl(IEC_FONT_SIZE);
    INDEX iFirstChar = GetIntFromControl(IEC_FIRST_CHAR);
    INDEX iLastChar = GetIntFromControl(IEC_LAST_CHAR);
    INDEX iAlignH  = GetComboIndex(IDC_ALIGN_H);
    INDEX iAlignV  = GetComboIndex(IDC_ALIGN_V);
    INDEX iPaddingX = GetIntFromControl(IEC_PADDINGX);
    INDEX iPaddingY = GetIntFromControl(IEC_PADDINGY);
    INDEX iWidthAdd = GetIntFromControl(IEC_WIDTH_ADD);
    INDEX iHeightAdd = GetIntFromControl(IEC_HEIGHT_ADD);
    INDEX ctShadows = GetIntFromControl(IEC_SHADOW_PASSES);
    
    if(ulFlags&FNT_HAS_SHADOW) {
      iPaddingX+=ctShadows;
      iPaddingY+=ctShadows;
      iWidthAdd+=ctShadows;
      iHeightAdd+=ctShadows;
    }

    _pfdCurrentFont = NULL;
    GenerateFont_t(_fdFont,_iiFont,_iiGrid,strFontName,iFontSize,iLastChar,iFirstChar,iAlignH,iAlignV,iPaddingX,iPaddingY,iWidthAdd,iHeightAdd,ulFlags,ctShadows);
    _pfdCurrentFont = &_fdFont;

    RefreshCanvas();
  } catch (char *strErr) {
    MessageBox(_hWnd,strErr,0,0);
  }
}
开发者ID:RocketersAlex,项目名称:LCSource,代码行数:56,代码来源:FontGen.cpp

示例10: fft_initialize

void fft_initialize( FFT_Tables *fft_tables )
{
	int i;
	fft_tables->costbl		= AllocMemory( (MAXLOGM+1) * sizeof( fft_tables->costbl[0] ) );
	fft_tables->negsintbl	= AllocMemory( (MAXLOGM+1) * sizeof( fft_tables->negsintbl[0] ) );
	fft_tables->reordertbl	= AllocMemory( (MAXLOGM+1) * sizeof( fft_tables->reordertbl[0] ) );
	
	for( i = 0; i< MAXLOGM+1; i++ )
	{
		fft_tables->costbl[i]		= NULL;
		fft_tables->negsintbl[i]	= NULL;
		fft_tables->reordertbl[i]	= NULL;
	}
}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:14,代码来源:fft.c

示例11: FreeMemory

// ---------------------------------------------------------------------
void DIBitmap::Create(
	SInt32 sizeX,		//!< horizontal size
	SInt32 sizeY		//!< vertical size
)
{
	if (NULL != bitmapInfo)
	{
		FreeMemory(bitmapInfo);
		bitmapInfo = NULL;
	}
	if (NULL != bits)
	{
		FreeMemory(bits);
		bits = NULL;
	}

	// allocates buffers for the header
	bitmapInfo = reinterpret_cast<BITMAPINFO*>(AllocMemory(sizeof(BITMAPINFO)));
	if (NULL == bitmapInfo)
	{
		MemoryException::Throw();
	}

	// sets header information
	BITMAPINFOHEADER* biP = &(bitmapInfo->bmiHeader);

	biP->biSize = sizeof(BITMAPINFOHEADER);
	biP->biWidth = sizeX;
	biP->biHeight = sizeY;
	biP->biPlanes = 1;
	biP->biBitCount = 24;
	biP->biCompression = BI_RGB;
	biP->biSizeImage = 0;
	biP->biXPelsPerMeter = 0;
	biP->biYPelsPerMeter = 0;
	biP->biClrUsed = 0;
	biP->biClrImportant = 0;

	// allocates buffers for each pixel bits
	SInt32 bitsSize = sizeY * getStorageWidth();
	bits = reinterpret_cast<Byte*>(AllocMemory(bitsSize));
	if (NULL == bits)
	{
		MemoryException::Throw();
	}

	// initializes all pixels with black color
	memset( bits, 0, bitsSize );
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:50,代码来源:DIBitmap.cpp

示例12: log10

char *ConvertLongToString (const int64 value)
{
	char *value_s = NULL;
	size_t num_digits = 1;

	if (value < 0)
		{
			size_t temp = (size_t) log10 ((double) -value);
			++ num_digits;

			num_digits += temp;
		}
	else if (value > 0)
		{
			num_digits += (size_t) log10 ((double) value);
		}

	value_s = (char *) AllocMemory (num_digits + 1);

	if (value_s)
		{
			sprintf (value_s, "%" PRId64 , value);
			* (value_s + num_digits) = '\0';
		}

	return value_s;
}
开发者ID:TGAC,项目名称:grassroots-api,代码行数:27,代码来源:string_utils.c

示例13: Map

	std::pair<u8*, u32> Map(u32 size) override
	{
		AllocMemory(size);
		u8* pointer = (u8*)glMapBufferRange(m_buffertype, m_iterator, size,
			GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
		return std::make_pair(pointer, m_iterator);
	}
开发者ID:BhaaLseN,项目名称:dolphin,代码行数:7,代码来源:StreamBuffer.cpp

示例14: reorder

static void reorder( FFT_Tables *fft_tables, double *x, int logm)
{
	int i;
	int size = 1 << logm;
	unsigned short *r;	//size


	if ( fft_tables->reordertbl[logm] == NULL ) // create bit reversing table
	{
		fft_tables->reordertbl[logm] = AllocMemory(size * sizeof(*(fft_tables->reordertbl[0])));

		for (i = 0; i < size; i++)
		{
			int reversed = 0;
			int b0;
			int tmp = i;

			for (b0 = 0; b0 < logm; b0++)
			{
				reversed = (reversed << 1) | (tmp & 1);
				tmp >>= 1;
			}
			fft_tables->reordertbl[logm][i] = reversed;
		}
	}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:25,代码来源:fft.c

示例15: gHyp_hyp_new

sHyp* gHyp_hyp_new ( char *method )
{
  /* Description:
   *
   *	Create a new program space. 
   *
   * Arguments:
   *
   *	method	[R]
   *	- name of method
   *
   * Return value:
   *
   *	Pointer to program's sHyp structure
   *
   */
  sHyp *pHyp = (sHyp*) AllocMemory ( sizeof ( sHyp ) ) ;
  assert ( pHyp ) ;
  strcpy ( pHyp->method, method ) ;
  pHyp->pCode = NULL ;
  pHyp->size = 0 ;
  pHyp->count = 0 ;
  pHyp->highWaterCount = pHyp->count ;

  gzTraceBufPrev[0] = '\0' ;
  gzTraceBufPrevPrev[0] = '\0' ;
  gzTraceBuf[0]     = '\0' ;

  /*  gHyp_util_logInfo("Creating Hyp %s",method ) ; */
  return pHyp ;
}
开发者ID:abinition,项目名称:hs,代码行数:31,代码来源:hyp.c


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