本文整理匯總了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;
}
示例2: delete1
BSplineBasis<Real>::~BSplineBasis ()
{
delete1(mKnot);
Deallocate(mBD0);
Deallocate(mBD1);
Deallocate(mBD2);
Deallocate(mBD3);
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例7: Deallocate
void Path :: Deallocate (Entry * good){
if (good != NULL){
Deallocate (good -> next);
delete good;
}
}
示例8: Deallocate
void DoublyLinkedListPriorityQueue:: Deallocate (Entry * & list){
if (list != NULL){
Deallocate (list -> next);
delete list;
}
}
示例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);
}
}
示例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;
}
示例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];
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}