bool CCTextureASTC::initWithContentsOfFileAsync(const char* path) { int len = 0; std::string lowerCase(path); if (lowerCase.find(".ccz") != std::string::npos) { len = ZipUtils::ccInflateCCZFile(path, &m_data); } else if (lowerCase.find(".gz") != std::string::npos) { len = ZipUtils::ccInflateGZipFile(path, &m_data); } else { m_data = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&len)); } if(len<0){ deleteData(); this->release(); return false; } m_uName = 0; m_uWidth = m_uHeight = 0; if (!unpackData(m_data)) { deleteData(); this->release(); return false; } /* Keep our GL texture name alive, even after we're destroyed. */ setRetainName(true); return true; }
/************************************************************* * Function : dictDelete * Author : bulldozer.ma * Date : 2015-11-01 * Input : char *str, dict *pHeader, unsigned int len * Output : N/A * Return : int * Other : N/A * Description : dictDelete **************************************************************/ int dictDelete(char *str, dict *pHeader, unsigned int len) { if (NULL == str || NULL == pHeader|| 0 >= len) { return DICT_ERROR; } int iRet = DICT_ERROR; dictht *ht = pHeader->ht[0]; iRet = deleteData(ht, str, len); if (DICT_ERROR == iRet) { return deleteData( pHeader->ht[1], str, len); } return iRet; }
// Reads a .tga file and creates an LLImageTGA with its data. bool LLImageTGA::loadFile( const LLString& path ) { S32 len = path.size(); if( len < 5 ) { return false; } LLString extension = path.substr( len - 4, 4 ); LLString::toLower(extension); if( ".tga" != extension ) { return false; } FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ if( !file ) { llwarns << "Couldn't open file " << path << llendl; return false; } S32 file_size = 0; if (!fseek(file, 0, SEEK_END)) { file_size = ftell(file); fseek(file, 0, SEEK_SET); } U8* buffer = allocateData(file_size); S32 bytes_read = fread(buffer, 1, file_size, file); if( bytes_read != file_size ) { deleteData(); llwarns << "Couldn't read file " << path << llendl; return false; } fclose( file ); if( !updateData() ) { llwarns << "Couldn't decode file " << path << llendl; deleteData(); return false; } return true; }
// Reads a .tga file and creates an LLImageTGA with its data. bool LLImageTGA::loadFile( const std::string& path ) { S32 len = path.size(); if( len < 5 ) { return false; } std::string extension = gDirUtilp->getExtension(path); if( "tga" != extension ) { return false; } LLFILE* file = LLFile::fopen(path, "rb"); /* Flawfinder: ignore */ if( !file ) { LL_WARNS() << "Couldn't open file " << path << LL_ENDL; return false; } S32 file_size = 0; if (!fseek(file, 0, SEEK_END)) { file_size = ftell(file); fseek(file, 0, SEEK_SET); } U8* buffer = allocateData(file_size); S32 bytes_read = fread(buffer, 1, file_size, file); if( bytes_read != file_size ) { deleteData(); LL_WARNS() << "Couldn't read file " << path << LL_ENDL; fclose(file); return false; } fclose( file ); if( !updateData() ) { LL_WARNS() << "Couldn't decode file " << path << LL_ENDL; deleteData(); return false; } return true; }
void urinalysis::initConnect() { //从串口获取数据 connect(m_port, SIGNAL(dataInfo(float,float)), this, SLOT(getPortData(float,float))); //给ARC赋值 connect(ui->ALBLineEdit, SIGNAL(textChanged(QString)), this, SLOT(setARC(QString))); connect(ui->CRELineEdit, SIGNAL(textChanged(QString)), this, SLOT(setARC(QString))); //清除 connect(ui->clearPushButton, SIGNAL(clicked()), this, SLOT(clearForms())); //查询 connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(fillTableWidget())); //保存数据 connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveData())); //显示tablewidget内容 connect(ui->tableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(setForms(int,int))); //关闭窗口 connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close())); //删除数据 connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteData())); //打印 connect(ui->printButton, SIGNAL(clicked()), this, SLOT(print())); }
// virtual U8* LLImageBase::allocateData(S32 size) { LLMemType mt1((LLMemType::EMemType)mMemType); if (size < 0) { size = mWidth * mHeight * mComponents; if (size <= 0) { llerrs << llformat("LLImageBase::allocateData called with bad dimentions: %dx%dx%d",mWidth,mHeight,mComponents) << llendl; } } else if (size <= 0 || (size > 4096*4096*16 && sSizeOverride == FALSE)) { llerrs << "LLImageBase::allocateData: bad size: " << size << llendl; } if (!mData || size != mDataSize) { deleteData(); // virtual mBadBufferAllocation = FALSE ; mData = new U8[size]; if (!mData) { llwarns << "allocate image data: " << size << llendl; size = 0 ; mWidth = mHeight = 0 ; mBadBufferAllocation = TRUE ; } mDataSize = size; } return mData; }
void Widget::mainProcedure(double** tempA, double* tempB, double* tempF) { //перевірка нетут, або взагалі непотрібна // if(!(nEq<nArgs)) // { // QMessageBox::critical(NULL,tr(""),tr("Невірні дані\nКількість невідомих повинна бути строго більше кількості рівнянь."),QMessageBox::Ok); // return; // } //перевіряємо обмеження for(int i=0;i<nEq;i++) { if(tempB[i]<0) { QMessageBox::critical(NULL,tr(""),tr("Невірні дані\nПеревірте вектор В."),QMessageBox::Ok); return; } } if(direction==tr("min")) { for(int i=0;i<nArgs;i++) tempF[i]=-tempF[i]; } //чистимо минулі данні deleteData(); //відправляємо дані на аналіз та створення першої симплекс таблиці genFirstSTable(tempA,tempF,tempB,rel); //запускаємо обчислення m_result=calc(); showHideInput(false); fillTables(); p2->setChecked(false); }
int main (int argc, char** argv) { struct usb_device *dev; if (argc < 2) { perr ("Should be called with one argument: 'read' or 'delete'\n", 2); } while (1) { if ((dev = findDev(0x0e6a, 0x0101)) == NULL) { perr ("Waiting for device...\n", 0); } else { break; } usleep (300000); } usb_dev_handle *hdl = open_device (dev); if (!strcmp(argv[1], "read")) { readData (hdl); } else if (!strcmp(argv[1], "delete")) { deleteData (hdl); } else { perr ("Invalid command line argument.\n", 3); } close_device (hdl); return 0; }
LLImageRaw::~LLImageRaw() { // NOTE: ~LLimageBase() call to deleteData() calls LLImageBase::deleteData() // NOT LLImageRaw::deleteData() deleteData(); --sRawImageCount; }
// virtual U8* LLImageBase::allocateData(S32 size) { LLMemType mt1(mMemType); if (size < 0) { size = mWidth * mHeight * mComponents; if (size <= 0) { llerrs << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << llendl; } } else if (size <= 0 || (size > 4096*4096*16 && !mAllowOverSize)) { llerrs << "LLImageBase::allocateData: bad size: " << size << llendl; } if (!mData || size != mDataSize) { deleteData(); // virtual mBadBufferAllocation = false ; mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!mData) { llwarns << "allocate image data: " << size << llendl; size = 0 ; mWidth = mHeight = 0 ; mBadBufferAllocation = true ; } mDataSize = size; } return mData; }
Widget::Widget(QWidget *parent) : QWidget (parent) { mainLayout=new QVBoxLayout(this); m_input=new inputWidget; m_help=new QWebView; m_help->load(QUrl("help/help.html")); QHBoxLayout* v=new QHBoxLayout; QPushButton* p1=new QPushButton(tr("Почати розрахунки")); QPushButton* pF=new QPushButton(tr("Завантажити з файлу")); p2=new QPushButton(tr("Показати поля вводу")); p2->setCheckable(true); p2->setChecked(true); QPushButton* p3=new QPushButton(tr("Очистити результати")); QPushButton* pH=new QPushButton(tr("Допомога")); p1->setMinimumWidth(160); p2->setMinimumWidth(200); p3->setMinimumWidth(200); v->addWidget(p1); v->addWidget(pF); v->addWidget(p2); v->addWidget(p3); v->addWidget(pH); m_buttonGroupBox=new QGroupBox; m_buttonGroupBox->setLayout(v); connect(p1,SIGNAL(clicked()),this,SLOT(getDatasFromForm())); connect(p2,SIGNAL(clicked(bool)),this,SLOT(showHideInput(bool))); connect(p3,SIGNAL(clicked()),this,SLOT(deleteData())); connect(pF,SIGNAL(clicked()),this,SLOT(getDatasFromFile())); connect(pH,SIGNAL(clicked()),this,SLOT(showHelp())); connect(m_input,SIGNAL(nEqChanged(QSize)),this,SLOT(myResize(QSize))); #ifdef WITH_EFFECTS QCheckBox* ch=new QCheckBox(tr("Увімкнути ефекти")); ch->setChecked(true); connect(ch,SIGNAL(clicked(bool)),this,SLOT(changeEffects(bool))); //v->addWidget(ch); m_enableEffects=true; m_ani=new QPropertyAnimation(this,"size"); #endif mainLayout->addWidget(m_buttonGroupBox,0,Qt::AlignTop); QVBoxLayout* m_inputL=new QVBoxLayout; m_inputL->addWidget(m_input); m_inputGB=new QGroupBox; m_inputGB->setLayout(m_inputL); mainLayout->addWidget(m_inputGB,0,Qt::AlignTop); mainLayout->addStretch(1); f=NULL; tablesScrollArea=NULL; tablesGroupBox=NULL; tablesLayout=NULL; m_isTables=false; m_isData=false; }
LLImageRaw::~LLImageRaw() { // NOTE: ~LLimageBase() call to deleteData() calls LLImageBase::deleteData() // NOT LLImageRaw::deleteData() deleteData(); --sRawImageCount; setInCache(false); }
CCTextureASTC::~CCTextureASTC() { if (m_uName != 0 && ! m_bRetainName) { ccGLDeleteTexture(m_uName); } deleteData(); }
void CharacterDataImpl::replaceData(unsigned int offset, unsigned int count, const DOMString &dat) { if (isReadOnly()) throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); deleteData(offset, count); insertData(offset, dat); };
int mycudaCompute() { // ri scrivo la funzione di update presente in dll "seriale" // utilizzando "GPUCompute(boidSet)" come chiamata cuda anzichè la normale "compute()" unsigned int simulationLenght,progress; int exitValue; int test=0; progress=0; simulationLenght=(unsigned int)ceil(simParameters.fps * simParameters.lenght); _Output(&cacheFileOption); while((!abortSimulation) && (progress<=simulationLenght)) { Channel *channels; channels=(Channel*)malloc(sizeof(Channel)*info.option); GPUCompute(boidSet); // data management cachingData(channels); // write data writeData(progress,channels); // update the index job progress simulationProgress = ((int)(100*progress)/simulationLenght); //advance to the next frame progress++; test++; // free channels memory freeChannel(channels); } simulationProgress=100; closeMethod(); if(abortSimulation) { printf("Simulation interrupted\n"); deleteData(); exitValue=INTERRUPTED_SIM; } // restoring abortSimulation flag abortSimulation=FALSE; exitValue=SUCCESS_SIM; // free resources free(boidSet); return exitValue; }
void DOMCharacterDataImpl::replaceData(const DOMNode *node, XMLSize_t offset, XMLSize_t count, const XMLCh *dat) { if (castToNodeImpl(node)->isReadOnly()) throw DOMException( DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMCharacterDataImplMemoryManager); deleteData(node, offset, count); insertData(node, offset, dat); }
Text* CDATASection::splitText(unsigned long offset) { Node* pParent = parentNode(); if (!pParent) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR); int n = length() - offset; Text* pNew = ownerDocument()->createCDATASection(substringData(offset, n)); deleteData(offset, n); pParent->insertBefore(pNew, nextSibling())->release(); return pNew; }
Map<keyType, valueType>& Map<keyType, valueType>::operator = (const Map<keyType, valueType> & rhs) { if(this == &rhs) return *this; if(this->size() > 0) { deleteData(); } addToThisFrom(rhs); return *this; }
BOOL LLImageRaw::resize(U16 width, U16 height, S8 components) { if ((getWidth() == width) && (getHeight() == height) && (getComponents() == components)) { return TRUE; } // Reallocate the data buffer. deleteData(); allocateDataSize(width,height,components); return TRUE; }
void WagProperty::deepCopy(const WagProperty &other) { _readOk = other._readOk; _propCode = other._propCode; _propType = other._propType; _propNum = other._propNum; _propSize = other._propSize; deleteData(); // Delete old data (If any) and set _propData to NULL if (other._propData != NULL) { _propData = new char[other._propSize + 1UL]; // Allocate space for property's data plus trailing zero memcpy(_propData, other._propData, other._propSize + 1UL); // Copy the whole thing } }
// update simulation void update() { unsigned int simulationLenght,progress; progress=0; simulationLenght=(unsigned int)ceil(simParameters.fps * simParameters.lenght); _Output(&cacheFileOption); while((!abortSimulation) && (progress<=simulationLenght)) { Channel *channels; channels=(Channel*)malloc(sizeof(Channel)*info.option); // compute Boids' new positions, velocities, accelerations compute(); // data management cachingData(channels); // write data writeData(progress,channels); // update Boids properties and kdtree updateBoids(); // update the index job progress simulationProgress = ((int)(100*progress)/simulationLenght); //advance to the next frame progress++; // free channels memory freeChannel(channels); } simulationProgress=100; closeMethod(); if(abortSimulation) { printf("Simulation interrupted\n"); deleteData(); } // restoring abortSimulation flag abortSimulation=FALSE; // free resources free(boidSet); kd_free(k3); }
ProjectCentral::ProjectCentral(const QString& PrjPath): mp_FXDesc(NULL),mp_AdvancedFXDesc(NULL) { openfluid::base::RuntimeEnvironment::instance()->linkToProject(); mp_FXDesc = new openfluid::fluidx::FluidXDescriptor(&m_IOListener); if (PrjPath == "") { setDefaultDescriptors(); } else { try { mp_FXDesc->loadFromDirectory(openfluid::base::ProjectManager::instance()->getInputDir()); } catch (openfluid::base::Exception& E) { //because we're in a constructor catch, so destructor is not called deleteData(); throw; } } try { mp_AdvancedFXDesc = new openfluid::fluidx::AdvancedFluidXDescriptor(*mp_FXDesc); } catch (openfluid::base::Exception& E) { //because we're in a constructor catch, so destructor is not called deleteData(); throw; } check(); }
void LLImageRaw::setDataAndSize(U8 *data, S32 width, S32 height, S8 components) { if(data == getData()) { return ; } deleteData(); LLImageBase::setSize(width, height, components) ; LLImageBase::setDataAndSize(data, width * height * components) ; sGlobalRawMemory += getDataSize(); }
int main() { float3 *A, *B; size_t size, i; size = N; A=allocData(size); B=allocData(size); initData(B,size,2.5); /* Perform the computation on the device */ #pragma acc parallel loop present(A,B) for (i=0; i < size; ++i) { A[i].x = B[i].x + (float) i; A[i].y = B[i].y + (float) i*2; A[i].z = B[i].z + (float) i*3; } /* Copy back the results */ #pragma acc update self(A[0:size]) printData(A, size); deleteData(A); deleteData(B); exit(0); }
void test_delete_integer_data_in_queue1() { Queue* queue = createQueue(); int removedData; int data1 = 10 , data2 = 20 , data3 = 30; insertData(queue , &data1 , 1); insertData(queue , &data2 , 3); insertData(queue , &data3 , 2); ASSERT(queue->length == 3); removedData =*(int*)deleteData(queue); ASSERT(queue->length == 2); ASSERT(removedData == 10); }
void test_delete_float_data_in_queue1() { Queue* queue = createQueue(); float deletedData; float data1 = 10.5 , data2 = 20.5 , data3 = 30.5; insertData(queue , &data1 , 1); insertData(queue , &data2 , 5); insertData(queue , &data3 , 2); insertData(queue , &data3 , 3); ASSERT(queue->length == 4); checkPriority(queue); deletedData = *(float*)deleteData(queue); ASSERT(queue->length == 3); ASSERT(deletedData == 10.5); }
void test_delete_string_data_in_queue() { Queue* queue = createQueue(); string deletedData; string data1 = "shital" , data2 = "shweta" , data3 = "shabarin"; insertData(queue , &data1 , 1); insertData(queue , &data2 , 5); insertData(queue , &data3 , 2); insertData(queue , &data3 , 3); ASSERT(queue->length == 4); checkPriority(queue); strcpy(deletedData , *(string*)deleteData(queue)); ASSERT(!strcmp(deletedData , "shital")); ASSERT(queue->length == 3); }
// virtual U8* LLImageBase::allocateData(S32 size) { if (size < 0) { size = mWidth * mHeight * mComponents; if (size <= 0) { LL_WARNS() << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << LL_ENDL; return NULL; } } //make this function thread-safe. static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16 ; //256 MB if (size < 1 || size > MAX_BUFFER_SIZE) { LL_INFOS() << "width: " << mWidth << " height: " << mHeight << " components: " << mComponents << LL_ENDL ; if(mAllowOverSize) { LL_INFOS() << "Oversize: " << size << LL_ENDL ; } else { LL_WARNS() << "LLImageBase::allocateData: bad size: " << size << LL_ENDL; return NULL; } } if (!mData || size != mDataSize) { deleteData(); // virtual mBadBufferAllocation = false ; mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!mData) { LL_WARNS() << "Failed to allocate image data, size: " << size << " width: " << mWidth << " height: " << mHeight << LL_ENDL; size = 0 ; mWidth = mHeight = 0 ; mBadBufferAllocation = true ; addAllocationError(); } mDataSize = size; claimMem(mDataSize); } return mData; }
// // Global Classes // SvcRecDialog::SvcRecDialog(const QString &svcname, QWidget *parent,const char *name) :QDialog(parent,name,true) { QFont font; font=QFont("Helvetica",12,QFont::Bold); font.setPixelSize(12); setCaption(QString().sprintf("%s %s",(const char *)svcname, (const char *)tr("Report Data"))); // // Datepicker // date_picker=new SvcRec(svcname,this,"date_picker"); date_picker->setGeometry(10,10, date_picker->sizeHint().width(), date_picker->sizeHint().height()); connect(date_picker,SIGNAL(dateSelected(const QDate &,bool)), this,SLOT(dateSelectedData(const QDate &,bool))); // // Delete Button // date_delete_button=new QPushButton(this,"date_delete_button"); date_delete_button-> setGeometry(10,sizeHint().height()-60,80,50); date_delete_button->setFont(font); date_delete_button->setText(tr("&Purge\nData")); connect(date_delete_button,SIGNAL(clicked()),this,SLOT(deleteData())); #ifndef WIN32 date_delete_button->setEnabled(rduser->deleteRec()&& date_picker->dayActive(date_picker->date().day())); #endif // WIN32 // // Close Button // QPushButton *button=new QPushButton(this,"close_button"); button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,80,50); button->setFont(font);\ button->setText(tr("&Close")); button->setDefault(true); connect(button,SIGNAL(clicked()),this,SLOT(closeData())); }
// virtual U8* LLImageBase::allocateData(S32 size) { LLMemType mt1(mMemType); if (size < 0) { size = mWidth * mHeight * mComponents; if (size <= 0) { llerrs << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << llendl; } } //make this function thread-safe. static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16 ; //256 MB if (size < 1 || size > MAX_BUFFER_SIZE) { llinfos << "width: " << mWidth << " height: " << mHeight << " components: " << mComponents << llendl ; if(mAllowOverSize) { llinfos << "Oversize: " << size << llendl ; } else { llerrs << "LLImageBase::allocateData: bad size: " << size << llendl; } } if (!mData || size != mDataSize) { deleteData(); // virtual mBadBufferAllocation = false ; mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!mData) { llwarns << "Failed to allocate image data size [" << size << "]" << llendl; size = 0 ; mWidth = mHeight = 0 ; mBadBufferAllocation = true ; } mDataSize = size; } return mData; }