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


C++ freeResources函数代码示例

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


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


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