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

C++ freeResources函数代码示例

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

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



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

示例1: scan_device

int scan_device()
{
  ocl_device_init();

  static char vendor_name[STRING_RETURN_SIZE];
  status = clGetDeviceInfo (device, CL_DEVICE_VENDOR, STRING_RETURN_SIZE, vendor_name, NULL);
  if(status != CL_SUCCESS) dump_error("Failed clGetDeviceInfo(CL_DEVICE_VENDOR)", status);
  printf ("Board vendor name: %s\n", vendor_name);

  // get all supported board names from MMD
  static char board_name[STRING_RETURN_SIZE];
  status = clGetDeviceInfo (device, CL_DEVICE_NAME, STRING_RETURN_SIZE, board_name, NULL);
  if(status != CL_SUCCESS) dump_error("Failed clGetDeviceInfo(CL_DEVICE_NAME)", status);
  printf ("Board name: %s\n\n", board_name);
  

  char *shared_buf1 = (char*)malloc(SHARED_BUFFER_SIZE * sizeof(char));
  char *shared_buf2 = (char*)malloc(SHARED_BUFFER_SIZE * sizeof(char));
  if (shared_buf1 == NULL || shared_buf2 == NULL) {
    dump_error("Failed to allocate two buffers with malloc", 0);
  }
  
  int i;
  for (i = 0; i < SHARED_BUFFER_SIZE; i++) {
    shared_buf1[i] = i;
    shared_buf2[i] = -1;
  }
  
  cl_mem in1 = clCreateBuffer (context, CL_MEM_READ_WRITE, SHARED_BUFFER_SIZE, NULL, &status);
  if(status != CL_SUCCESS) dump_error("Failed clCreateBuffer for in1", status);
  
  status = clEnqueueWriteBuffer (queue, in1, CL_TRUE, 0, SHARED_BUFFER_SIZE, shared_buf1, 0, NULL, NULL);
  if (status != CL_SUCCESS) dump_error("Could not launch clEnqueueWriteBuffer!", status);
  
  status = clEnqueueReadBuffer (queue, in1, CL_TRUE, 0, SHARED_BUFFER_SIZE, shared_buf2, 0, NULL, NULL);
  if (status != CL_SUCCESS) dump_error("Could not launch clEnqueueWriteBuffer!", status);
  
  for (i = 0; i < SHARED_BUFFER_SIZE; i++) {
    if (shared_buf1[i] != shared_buf2[i] ) {
      printf("\nBuffer comparison failed!\n");
      printf ("#%d: %d vs %d\n", i, shared_buf1[i], shared_buf2[i]);
      freeResources();
      return -1;
    }
  }
  printf ("Buffer read/write test passed.\n");

  free (shared_buf1);
  free (shared_buf2);
  clReleaseMemObject (in1);
  freeResources();
  return 0;
}
开发者ID:dwesterg,项目名称:soc-workshop,代码行数:53,代码来源:diagnostic.c


示例2: freeResources

void TrainTask::returnUnit(Unit unit)
{
	if(mProductionBuilding == unit)
	{
		freeResources();
		mProductionBuilding = StaticUnits::nullunit;
	}
	else if(mProducedUnit == unit)
	{
		freeResources();
		mProducedUnit = StaticUnits::nullunit;
	}
	else
		assert(false);
}
开发者ID:Excolo,项目名称:StarcraftBot,代码行数:15,代码来源:TrainTask.cpp


示例3: freeAlgResources

/*
 *  ======== freeAlgResources ========
 */
static Bool freeAlgResources(BUFALG_TI_Handle alg, IRES_Fxns *fxns,
        Int scratchId)
{
    IRES_ResourceDescriptor desc[MAXDESCS];
    IALG_Handle             h = (IALG_Handle)alg;
    Int                     numRes;
    Int                     status;

    numRes = (fxns->numResourceDescriptors)(h);
    if (numRes > MAXDESCS) {
        System_printf("Too many resources: %d\n", numRes);
        return (FALSE);
    }

    System_printf("Number of resources: %d\n", numRes);

    status = (fxns->getResourceDescriptors)(h, desc);

    if (status != IRES_OK) {
        System_printf("Failed to get resource descriptors\n");
        return (FALSE);
    }

    freeResources(h, desc, numRes, scratchId);

    return (TRUE);
}
开发者ID:andreimironenko,项目名称:framework_components,代码行数:30,代码来源:bufres_test.c


示例4: DesktopWindow

DesktopWindowLinux::DesktopWindowLinux(DesktopWindowClient* client, int width, int height)
    : DesktopWindow(client, width, height)
    , m_eventSource(0)
    , m_display(0)
    , m_window(0)
    , m_im(0)
    , m_ic(0)
    , m_cursor(0)
    , m_currentX11Cursor(XC_left_ptr)
    , m_lastClickTime(0)
    , m_lastClickX(0)
    , m_lastClickY(0)
    , m_lastClickButton(kWKEventMouseButtonNoButton)
    , m_clickCount(0)
{
    try {
        setup();
    } catch(const FatalError&) {
        freeResources();
        throw;
    }

    m_eventSource = new XlibEventSource(m_display, this);

    makeCurrent();
    glEnable(GL_DEPTH_TEST);
}
开发者ID:dakerfp,项目名称:drowser,代码行数:27,代码来源:DesktopWindowLinux.cpp


示例5: freeResources

MediaImpl::~MediaImpl()
{
  freeResources();
  /* _data points to gstreamer-allocated data, we don't manage it ourselves */
  //if (_data)
  //  free(_data);
}
开发者ID:MatiasDelera,项目名称:mapmap,代码行数:7,代码来源:MediaImpl.cpp


示例6: xsltParseStylesheetFile

Xsltproc::ReturnValue Xsltproc::execute()
{
    Xsltproc::ReturnValue retval = Xsltproc::Success;
    try
    {
        if( freopen(mErrorFilename.toUtf8().data(),"w",stderr) == NULL ) throw Xsltproc::GenericFailure;

        mStylesheet = xsltParseStylesheetFile( (const xmlChar*)mStyleSheetFilename.toUtf8().data() );
        if(mStylesheet == 0) throw Xsltproc::InvalidStylesheet;

        mXml = xmlParseFile( (const char*)mXmlFilename.toUtf8().data() );
        if(mXml == 0) throw Xsltproc::InvalidXmlFile;

        mOutput = xsltApplyStylesheet(mStylesheet, mXml, (const char**)mParams);
        if(mOutput == 0) throw Xsltproc::GenericFailure;

        FILE *foutput = 0;
        foutput = fopen(mOutputFilename.toUtf8().data(),"w");
        if( foutput == 0 ) throw Xsltproc::CouldNotOpenOutput;
        xsltSaveResultToFile(foutput, mOutput, mStylesheet);
        fclose(foutput);
    }
    catch(Xsltproc::ReturnValue e)
    {
        retval = e;
    }

    fclose(stderr);

    freeResources();

    return retval;
}
开发者ID:adamb924,项目名称:Gloss,代码行数:33,代码来源:xsltproc.cpp


示例7: freeResources

 void TreeBuilder::initialiseParse(const StringRef& input, const StringRef& baseUri, ParseErrorList* errors, Allocator* allocator) {
     freeResources();
     
     CSOUP_ASSERT(input.size() > 0 && input.data() != NULL);
     CSOUP_ASSERT(baseUri.size() > 0 && baseUri.data() != NULL);
     
     // Don't destroy this
     errors_ = errors;
     
     if (allocator == NULL) {
         // if invoked didn't give an allocator, you should pass NULL to Document's construtor
         // and update allocator.
         // User can destroy the document using delete expression. And this should be the usual case.
         doc_ = new Document(baseUri, allocator);
         allocator = doc_->allocator();
     } else {
         // when user specify the allocator, you should initialize memory for Document from it.
         // User must invoke free of allocator in order to destroy Document.
         // User shouldn't use this style except the some extreme cases.
         doc_ = new (allocator->malloc_t<Document>()) Document(baseUri, allocator);
     }
     
     reader_ = new (allocator->malloc_t<CharacterReader>()) CharacterReader(input);
     tokeniser_ = new (allocator->malloc_t<Tokeniser>()) Tokeniser(reader_, errors, allocator);
     stack_ = new (allocator->malloc_t< internal::Vector<Element*> >()) internal::Vector<Element*>(4, allocator);
     baseUri_ = new (allocator->malloc_t< String>()) String(baseUri, allocator);
     allocator_ = allocator;
     currentToken_ = NULL;
 }
开发者ID:xingdong0625,项目名称:csoup,代码行数:29,代码来源:treebuilder.cpp


示例8: freeResources

ExVPJoinTcb::~ExVPJoinTcb()
{
  delete qParent_.up;
  delete qParent_.down;

  freeResources();
}
开发者ID:qwertyioz,项目名称:incubator-trafodion,代码行数:7,代码来源:ExVPJoin.cpp


示例9: freeResources

ExFastExtractTcb::~ExFastExtractTcb()
{
  // Release resources acquired
  //
  freeResources();

  delete qParent_.up;
  delete qParent_.down;
 
  if (workAtp_)
  {
    workAtp_->release();
    deallocateAtp(workAtp_, getSpace());
  }

  if (inSqlBuffer_ && getHeap())
  {
    getHeap()->deallocateMemory(inSqlBuffer_);
    inSqlBuffer_ = NULL;
    childOutputTD_ = NULL;
  }
  if (sourceFieldsConvIndex_)
    getHeap()->deallocateMemory(sourceFieldsConvIndex_);

} // ExFastExtractTcb::~ExFastExtractTcb()
开发者ID:sandhyasun,项目名称:incubator-trafodion,代码行数:25,代码来源:ExFastTransport.cpp


示例10: deallocateAtp

ExExeUtilTcb::~ExExeUtilTcb()
{
  delete qparent_.up;
  delete qparent_.down;
  if (workAtp_)
    {
      workAtp_->release();
      deallocateAtp(workAtp_, getGlobals()->getSpace());
      workAtp_ = NULL;
    }
  freeResources();

  if (extractedPartsObj_)
    {
      delete extractedPartsObj_;
      extractedPartsObj_ = NULL;
    }
  if (explQuery_)
    NADELETEBASIC(explQuery_, getHeap());
  if (childQueryId_ != NULL)
  {
    NADELETEBASIC(childQueryId_, getHeap());
    childQueryId_ = NULL;
    childQueryIdLen_ = 0;
  }
  if (outputBuf_ != NULL)
  {
    NADELETEBASIC(outputBuf_, getHeap());
    outputBuf_ = NULL;
    outputBuf_ = 0;
  }

};
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:33,代码来源:ExExeUtilCommon.cpp


示例11: LOGMESSAGE

void ConstructionTask::giveUnit(Unit unit)
{
	if(unit->getType() == mType.whatBuilds().first)
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Given Builder");
		assert(!mBuilder);
		mBuilder = unit;
		reserveResources();
	}
	else if(unit == mReservedLocation->getUnitPrediction() || unit->getTilePosition() == mReservedLocation->getTilePosition())
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Given Produced Unit");

		assert(!mProducedUnit || !mProducedUnit->exists());

		mProducedUnit = unit;
		if(mProducedUnit->exists())
		{
			freeResources();
			freeLocation();
		}
	}
	else
		assert(false);
}
开发者ID:SPQRBrutus,项目名称:skynetbot,代码行数:25,代码来源:ConstructionTask.cpp


示例12: freeResources

X11Grabber::~X11Grabber()
{
	if (_x11Display != nullptr)
	{
		freeResources();
		XCloseDisplay(_x11Display);
	}
}
开发者ID:XfableX,项目名称:hyperion.ng,代码行数:8,代码来源:X11Grabber.cpp


示例13: freeResources

MediaImpl::~MediaImpl()
{
    // Free all resources.
    freeResources();

    // Free mutex locker object.
    delete _mutexLocker;
}
开发者ID:guozanhua,项目名称:mapmap,代码行数:8,代码来源:MediaImpl.cpp


示例14: main

int main( int argc, char** argv )
{
	srand (time(NULL));
	init_platform();
	run();
	freeResources();
	return 0;
}
开发者ID:mapleelpam,项目名称:openCL-string-compare,代码行数:8,代码来源:main.cpp


示例15: freeResources

SharedMemoryBlock::~SharedMemoryBlock() {
	// Destructor sin lanzamiento de excepciones
	try {
		freeResources();
	}
	catch(const SharedMemoryException &e) {
	}
}
开发者ID:mlucero88,项目名称:ConcuCalesita,代码行数:8,代码来源:SharedMemoryBlock.cpp


示例16: freeResources

void GL3LightingManager::resizeFramebuffer(uint32_t width, uint32_t height) {
    // First check if the new size is actually bigger than the old
    if (width <= _framebufferSize.x && height <= _framebufferSize.y) {
        return; // Framebuffer is big enough, no need to change the size
    }

    freeResources();

    createFrameBuffer(width, height);
}
开发者ID:DahBlount,项目名称:GL3Test,代码行数:10,代码来源:GL3LightingManager.cpp


示例17: qDebug

void ParticleSystem::slotSetParticleRadius(float radius)
{
    qDebug() << "ParticleSystem::slotSetParticleRadius(): setting particle radius from" << mParametersSimulation->particleRadius << "to" << radius;
    mParametersSimulation->particleRadius = radius;

    // Need to rebuild data-structures when particle radius or -count changes.
    if(mIsInitialized) freeResources();

    //slotInitialize(); will happen lazily on update
}
开发者ID:wpfhtl,项目名称:octocopter,代码行数:10,代码来源:particlesystem.cpp


示例18: getShaderSource

Shader::Shader(const std::string& vertShader, const std::string& fragShader)
{
    auto vertSrc = getShaderSource(vertShader);
    auto fragSrc = getShaderSource(fragShader);

    createVertexShader(vertSrc);
    createFragmentShader(fragSrc);
    createProgram();
    freeResources();
}
开发者ID:jhpy1024,项目名称:Mazel,代码行数:10,代码来源:Shader.cpp


示例19: XGetWindowAttributes

int X11Grabber::updateScreenDimensions()
{
	const Status status = XGetWindowAttributes(_x11Display, _window, &_windowAttr);
	if (status == 0)
	{
		Error(_log, "Failed to obtain window attributes");
		return -1;
	}

	if (_screenWidth == unsigned(_windowAttr.width) && _screenHeight == unsigned(_windowAttr.height))
	{
		// No update required
		return 0;
	}

	if (_screenWidth || _screenHeight)
	{
		freeResources();
	}

	Info(_log, "Update of screen resolution: [%dx%d]  to [%dx%d]", _screenWidth, _screenHeight, _windowAttr.width, _windowAttr.height);
	_screenWidth  = _windowAttr.width;
	_screenHeight = _windowAttr.height;
	
	// Image scaling is performed by XRender when available, otherwise by ImageResampler
	if (_XRenderAvailable && !_useXGetImage)
	{
		_croppedWidth  =  (_screenWidth > unsigned(_cropLeft + _cropRight))
			? ((_screenWidth - _cropLeft - _cropRight) / _horizontalDecimation)
			: _screenWidth / _horizontalDecimation;
		
		_croppedHeight =  (_screenHeight > unsigned(_cropTop + _cropBottom))
			? ((_screenHeight - _cropTop - _cropBottom) / _verticalDecimation)
			: _screenHeight / _verticalDecimation;
			
		Info(_log, "Using XRender for grabbing");
	}
	else
	{
		_croppedWidth  =  (_screenWidth > unsigned(_cropLeft + _cropRight))
			? (_screenWidth - _cropLeft - _cropRight)
			: _screenWidth;
		
		_croppedHeight =  (_screenHeight > unsigned(_cropTop + _cropBottom))
			? (_screenHeight - _cropTop - _cropBottom)
			: _screenHeight;
			
		Info(_log, "Using XGetImage for grabbing");
	}

	_image.resize(_croppedWidth, _croppedHeight);
	setupResources();

	return 1;
}
开发者ID:XfableX,项目名称:hyperion.ng,代码行数:55,代码来源:X11Grabber.cpp


示例20: freeResources

void UVAnimParticleQuadSystem::setTextureWithRectForAnimation(Texture2D *texture, const Rect& rect, 
	int tileWidth, int tileHeight, int number_Frames_per_Second, bool NeedsToRemoveParticleAfterAniamtion) {
    m_nItemWidth = tileWidth;
    m_nItemHeight = tileHeight;
    m_bNeedsToRemoveParticleAfterAniamtion = NeedsToRemoveParticleAfterAniamtion;

	if (texture && tileWidth > 0 && tileHeight > 0 && number_Frames_per_Second > 0) {
	    const Size& s = texture->getContentSizeInPixels();
		m_nItemsPerColumn = (int)(s.height / m_nItemHeight);
		m_nItemsPerRow = (int)(s.width / m_nItemWidth);
		m_nFrameCount = m_nItemsPerRow * m_nItemsPerColumn;
        m_fFrameRate = 1.f / number_Frames_per_Second;
		
	    const float inv_wide = 1.f/texture->getPixelsWide();
        const float inv_high = 1.f/texture->getPixelsHigh();

		freeResources();

		const int UVCount = (m_nItemsPerColumn+1) * (m_nItemsPerRow+1);
		m_pTexCoords = new Tex2F[UVCount];
		Tex2F *texPtr = m_pTexCoords;
		// Important. Texture in cocos2d are inverted, so the Y component should be inverted
		for (int j = 0; j <= m_nItemsPerColumn; ++j) {
			const float y = (rect.origin.y + m_nItemHeight*j)*inv_high;
			for (int i = 0; i <= m_nItemsPerRow; ++i) {
				texPtr->u = (rect.origin.x + m_nItemWidth*i)*inv_wide;
				texPtr->v = y;
				++texPtr;
			}
		}

		m_pUVRects = new UVRect[m_nFrameCount];
		UVRect *rectPtr = m_pUVRects;
		for (int j = 0; j < m_nItemsPerColumn; ++j) {
			Tex2F *texPtr = m_pTexCoords + j * (m_nItemsPerRow+1);
			for (int i = 0; i < m_nItemsPerRow; ++i) {
				Tex2F *ptr = texPtr + i;
				rectPtr->tl = ptr;
				rectPtr->tr = ptr + 1;
				rectPtr->bl = ptr + m_nItemsPerRow + 1;
				rectPtr->br = ptr + m_nItemsPerRow + 2;
				//CCLOG("%f,%f;%f,%f;%f,%f;%f,%f;",  \
					rectPtr->tl->u,rectPtr->tl->v, \
					rectPtr->tr->u,rectPtr->tr->v, \
					rectPtr->bl->u,rectPtr->bl->v, \
					rectPtr->br->u,rectPtr->br->v);
				++rectPtr;
			}
		}

		ParticleSystemQuad::setTextureWithRect(texture, Rect(rect.origin.x, rect.origin.y, tileWidth, tileHeight));
	} else {
开发者ID:jbyu,项目名称:cocos2d-x-particleAnim,代码行数:52,代码来源:UVAnimParticleQuadSystem.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ freeTree函数代码示例发布时间:2022-05-30
下一篇:
C++ freeReplyObject函数代码示例发布时间: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