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


C++ Deallocate函数代码示例

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


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

示例1: Deallocate

moDMatrix<Real>& moDMatrix<Real>::operator= (const moDMatrix& rkM)
{
    if (rkM.m_iQuantity > 0)
    {
        if (m_iRows != rkM.m_iRows || m_iCols != rkM.m_iCols)
        {
            Deallocate();
            m_iRows = rkM.m_iRows;
            m_iCols = rkM.m_iCols;
            m_iQuantity = rkM.m_iQuantity;
            Allocate(false);
        }
        for (int iRow = 0; iRow < m_iRows; iRow++)
        {
            for (int iCol = 0; iCol < m_iCols; iCol++)
            {
                m_aafEntry[iRow][iCol] = rkM.m_aafEntry[iRow][iCol];
            }
        }
    }
    else
    {
        Deallocate();
        m_iRows = 0;
        m_iCols = 0;
        m_iQuantity = 0;
        m_afData = 0;
        m_aafEntry = 0;
    }
    return *this;
}
开发者ID:moldeo,项目名称:libmoldeo,代码行数:31,代码来源:moMathDMatrix.cpp

示例2: delete1

BSplineBasis<Real>::~BSplineBasis ()
{
	delete1(mKnot);
	Deallocate(mBD0);
	Deallocate(mBD1);
	Deallocate(mBD2);
	Deallocate(mBD3);
}
开发者ID:ascetic85,项目名称:Phoenix3d,代码行数:8,代码来源:PX2BSplineBasis.cpp

示例3: new

Adventure::ITexture* Adventure::Image::LoadTgaFromFile(File& file, IDisplay& display, Allocator* scratch)
{
	file.GetStream().seekg(2, std::ios::beg);
	
	File::UInt8 type;
	file.Read(type);
	
	if (type != 2) // Type 2 indicates a regular image
		return NULL;
	
	file.GetStream().seekg(12, std::ios::beg);
	
	File::UInt16 width, height;
	file.Read(width);
	file.Read(height);
	
	int pixels = width * height;
	
	file.GetStream().seekg(16, std::ios::beg);
	
	File::UInt8 bits;
	file.Read(bits);
	
	if (bits < 24)
		return NULL;
	
	file.GetStream().seekg(18, std::ios::beg);
	
	Color* pixelData = new(scratch) Color[pixels];
	
	for (int i = 0; i < pixels; i++)
	{
		// BGRA format
		file.Read(pixelData[i].Blue);
		file.Read(pixelData[i].Green);
		file.Read(pixelData[i].Red);
		
		if (bits == 32)
			file.Read(pixelData[i].Alpha);
		else
			pixelData[i].Alpha = Color::MaxChannelValue;
	}
	
	ITexture* texture = display.CreateTexture();
	
	if (texture == NULL)
	{
		Deallocate(pixelData, scratch);
		return NULL;
	}
	
	texture->SetData(pixelData, width, height, ITexture::Rgba8, ITexture::Point);
	
	Deallocate(pixelData, scratch);
		
	return texture;
}
开发者ID:aaronbolyard,项目名称:Egoboo-Wii,代码行数:57,代码来源:Image.cpp

示例4: Deallocate

template <class T> void Vector<T>::CopyToSelf(Vector const & source)
{
	UInt length;
	ConstElement *it, *source_it, *source_end;

	Deallocate();
	_ctorMode = source._ctorMode;

	if(!source.IsEmpty())
	{
		length = source.Length();
		Allocate(length);

		it = _origin;
		source_it = source.Begin();
		source_end = source.End();

		if(_ctorMode != CtorModeEnum::Always)
		{
			Memory::Move((VoidPtr)source_it, (VoidPtr)it, sizeof(Element) * length);
			_last += length;
		}
		else
			while(source_it != source_end)
			{
				Construct(it++, source_it++);
				++_last;
			}
	}
}
开发者ID:Karkasos,项目名称:Core,代码行数:30,代码来源:Vector.cpp

示例5: LOG

void
MediaEngineWebRTCVideoSource::Shutdown()
{
  LOG((__FUNCTION__));
  if (!mInitDone) {
    return;
  }
#ifdef MOZ_B2G_CAMERA
  ReentrantMonitorAutoEnter sync(mCallbackMonitor);
#endif
  if (mState == kStarted) {
    while (!mSources.IsEmpty()) {
      Stop(mSources[0], kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  if (mState == kAllocated || mState == kStopped) {
    Deallocate();
  }
#ifndef MOZ_B2G_CAMERA
  mViECapture->Release();
  mViERender->Release();
  mViEBase->Release();
#endif
  mState = kReleased;
  mInitDone = false;
}
开发者ID:Gabuzo,项目名称:mozilla-central,代码行数:28,代码来源:MediaEngineWebRTCVideo.cpp

示例6: Deallocate

	void EpsilonVor::ReadIt(std::ifstream & fin){
		Matrix co0,oc0;
		fin.read((char *) &nnx, sizeof nnx);
		fin.read((char *) &nny, sizeof nny);
		fin.read((char *) &nnz, sizeof nnz);
		fin.read((char *) &co0, sizeof co0);
		fin.read((char *) &oc0, sizeof oc0);
		fin.read((char *) &nresid, sizeof nresid);
		Deallocate();
		is_xRefset=true;
		is_COset=true;
		setMetric(co0);
		Allocate();
		int ntoken;
		fin.read((char *) &ntoken, sizeof ntoken);
		char * css=new char [ntoken];
		fin.read(css, (sizeof css[0])*ntoken);
		string token(css);
		ResLabel.clear();

		boost::split(ResLabel,token, boost::is_any_of("\t "));

		fin.read((char *) &TotalCount, sizeof TotalCount);
		fin.read((char *) &M_avg[0], (sizeof M_avg[0])*DIM);
		fin.read((char *) &VoroVol[0], (sizeof VoroVol[0])*nresid);
		fin.read((char *) &D[0][0][0], (sizeof D[0][0][0])*DIM*DIM*nresid);
		fin.read((char *) &G[0][0][0], (sizeof G[0][0][0])*DIM*DIM*nresid);
		fin.read((char *) &M[0][0], (sizeof M[0][0])*DIM*nresid);
		fin.read((char *) &E[0][0], (sizeof E[0][0])*DIM*nresid);
	}
开发者ID:mm148881,项目名称:postnoneqx,代码行数:30,代码来源:EpsilonVor.cpp

示例7: Deallocate

void Path :: Deallocate (Entry *  good){
    
    if (good != NULL){
        Deallocate (good -> next);
        delete good;
    }
}
开发者ID:Jfeng3,项目名称:CS106B---Stanford,代码行数:7,代码来源:path+.cpp

示例8: Deallocate

void DoublyLinkedListPriorityQueue:: Deallocate (Entry * & list){
    
    if (list != NULL){
        Deallocate (list -> next);
        delete list;
    }
}
开发者ID:Jfeng3,项目名称:CS106B---Stanford,代码行数:7,代码来源:pqueue-doublylinkedlist+.cpp

示例9: Deallocate

void TileGrid2D::Resize(Vector2i newSize)
{
	std::cout<<"\nTileGrid2D::Resize";
	Deallocate();
	size = newSize;
	/// Space in X between the columns, use for creating hexagonal grids, since the distance between each tile should always be 1.0 if possible.
	float spaceX = 0;
	/// Offset in Y, used for creating hexagonal grids.
	Vector2f eachOtherRowOffset;
	Vector2f rowSpacing(1,1);
	if (gridType == GridType::HEXAGONS)
	{
		eachOtherRowOffset = Vector2f(0.5f, 0);
		rowSpacing = Vector2f(1, 0.86602540378f);
	}

	for (int y = 0; y < size[1]; ++y)
	{
		List<Tile*> * list = new List<Tile*>();
		for (int x = 0; x < size[0]; ++x)
		{
			Tile * tile = new Tile();
			tile->position = rowSpacing.ElementMultiplication(Vector2f(x,y));
			if (y % 2 == 0)
				tile->position += eachOtherRowOffset;
			list->Add(tile);
		}
		tiles.Add(list);
	}
}
开发者ID:erenik,项目名称:engine,代码行数:30,代码来源:TileGrid2D.cpp

示例10: Deallocate

void	CARingBuffer::Allocate(int nChannels, UInt32 bytesPerFrame, UInt32 capacityFrames)
{
	Deallocate();
	
	//capacityFrames = NextPowerOfTwo(capacityFrames);
	
	mNumberChannels = nChannels;
	mBytesPerFrame = bytesPerFrame;
	mCapacityFrames = capacityFrames;
	//mCapacityFramesMask = capacityFrames - 1;
	mCapacityBytes = bytesPerFrame * capacityFrames;

	// put everything in one memory allocation, first the pointers, then the deinterleaved channels
	UInt32 allocSize = (mCapacityBytes + sizeof(Byte *)) * nChannels;
	Byte *p = (Byte *)CA_malloc(allocSize);
	memset(p, 0, allocSize);
	mBuffers = (Byte **)p;
	p += nChannels * sizeof(Byte *);
	for (int i = 0; i < nChannels; ++i) {
		mBuffers[i] = p;
		p += mCapacityBytes;
	}
	
	for (UInt32 i = 0; i<kGeneralRingTimeBoundsQueueSize; ++i)
	{
		mTimeBoundsQueue[i].mStartTime = 0;
		mTimeBoundsQueue[i].mEndTime = 0;
		mTimeBoundsQueue[i].mUpdateCounter = 0;
	}
	mTimeBoundsQueuePtr = 0;
}
开发者ID:kybernetyk,项目名称:SSUIKit,代码行数:31,代码来源:CARingBuffer.cpp

示例11: Deallocate

void CTexture::Allocate( int width, int height, int ctype )
{
if ( (m_width == width) && (m_height == height) && (m_type == ctype) )
	return;

Deallocate();

TextureGetSize( ctype, &m_compsize, &m_pixelsize, &m_nelements );

if ( m_compsize == 0 || m_pixelsize == 0 || m_nelements == 0)     // Sanity check 
	{
	printf ("CTexture::Allocate - Unknown format %08X\n", ctype );
  return;
	}

m_width  = width;
m_height = height;
m_area   = width * height;
m_type   = ctype;
m_size   = m_area * m_pixelsize;
m_pdata  = new TEXBYTE[m_size];

m_pitch  = m_pixelsize * m_width;

if ( ctype == TEX_PALETTE )
		m_pcolormap = new colmap4f[256];

}
开发者ID:mistalro,项目名称:gpufractal,代码行数:28,代码来源:texture.cpp

示例12: LOG

void
MediaEngineWebRTCVideoSource::Shutdown()
{
  LOG((__FUNCTION__));
  if (!mInitDone) {
    return;
  }
  if (mState == kStarted) {
    SourceMediaStream *source;
    bool empty;

    while (1) {
      {
        MonitorAutoLock lock(mMonitor);
        empty = mSources.IsEmpty();
        if (empty) {
          break;
        }
        source = mSources[0];
      }
      Stop(source, kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  if (mState == kAllocated || mState == kStopped) {
    Deallocate();
  }
  mViECapture = nullptr;
  mViERender = nullptr;
  mViEBase = nullptr;

  mState = kReleased;
  mInitDone = false;
}
开发者ID:nafis-sadik,项目名称:gecko-dev,代码行数:35,代码来源:MediaEngineWebRTCVideo.cpp

示例13: Deallocate

void	FSTCARingBuffer::AllocateWithABL(const AudioBufferList *abl)								// Assumes floating-point data
{
	Deallocate();
	
	if(abl->mNumberBuffers == 0)
		return;
	
	UInt32 idx, byteSize = offsetof(AudioBufferList, mBuffers[0]) + (sizeof(AudioBuffer) * abl->mNumberBuffers);
	mBufferList = (AudioBufferList *)malloc(byteSize);
	memset(mBufferList, 0, byteSize);
	
	mBufferList->mNumberBuffers = abl->mNumberBuffers;
	for(idx=0; idx<mBufferList->mNumberBuffers; idx++)
	{
		mBufferList->mBuffers[idx].mNumberChannels = abl->mBuffers[idx].mNumberChannels;
		mBufferList->mBuffers[idx].mDataByteSize = abl->mBuffers[idx].mDataByteSize;
		mBufferList->mBuffers[idx].mData = malloc(mBufferList->mBuffers[idx].mDataByteSize);
	}
	
	mCapacityFrames = abl->mBuffers[0].mDataByteSize/abl->mBuffers[0].mNumberChannels/sizeof(float);
	
	for (UInt32 i = 0; i<kFSTGeneralRingTimeBoundsQueueSize; ++i)
	{
		mTimeBoundsQueue[i].mStartTime = 0;
		mTimeBoundsQueue[i].mEndTime = 0;
		mTimeBoundsQueue[i].mUpdateCounter = 0;
	}
	mTimeBoundsQueuePtr = 0;
}
开发者ID:TannerPlauche,项目名称:VowelViz-Standard-iOS,代码行数:29,代码来源:FSTCARingBuffer.cpp

示例14: LOG

void
MediaEngineGonkVideoSource::Shutdown()
{
  LOG((__FUNCTION__));
  if (!mInitDone) {
    return;
  }

  ReentrantMonitorAutoEnter sync(mCallbackMonitor);

  if (mState == kStarted) {
    SourceMediaStream *source;
    bool empty;

    while (1) {
      {
        MonitorAutoLock lock(mMonitor);
        empty = mSources.IsEmpty();
        if (empty) {
          break;
        }
        source = mSources[0];
      }
      Stop(source, kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  if (mState == kAllocated || mState == kStopped) {
    Deallocate();
  }

  mState = kReleased;
  mInitDone = false;
}
开发者ID:nafis-sadik,项目名称:gecko-dev,代码行数:35,代码来源:MediaEngineGonkVideoSource.cpp

示例15: Deallocate

bool tTexture::LoadImage(std::string filename) {
	//This function uses the surface to load an image, then create a texture out of it

	Deallocate();

	//Create a "Guinna Pig" texture
	SDL_Texture* thePig = NULL;

	//Load a BMP into theSurface. BMP Is the only file type that native SDL2 can import. W(e will have to add SDL2_image to import other formats)
	theSurface = SDL_LoadBMP(filename.c_str()); //SDL_LoadBMP expects a ( char[] )

	//Debug VV
	if(theSurface == NULL) {
		std::cout << "Could not Load image! : " << SDL_GetError() <<std::endl;
	} else {
		//theTexture = SDL_CreateTextureFromSurface(theRenderer, theSurface);
		thePig = SDL_CreateTextureFromSurface(theRenderer, theSurface);

		//Debug VV
		if(thePig == NULL) {
			std::cout << "Could not create texture! : " << SDL_GetError() <<std::endl;
		}
		//Set the height and width. -> ->(Remember that theSurface is a pointer)
		tWidth = theSurface->w;
		tHeight = theSurface->h;
		//We are going to recycle our global "Surface"
		SDL_FreeSurface(theSurface);
		theSurface = NULL;
	}


	//Here is where we copy thePig into sTexture: If anything went wrong, thePig would have been NULL
	sTexture = thePig;
	return sTexture != NULL;
}
开发者ID:ChillieDude,项目名称:TixTaxToo,代码行数:35,代码来源:functions.cpp


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