diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 537f3f195..0a89c0b95 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -84,12 +84,12 @@ void UDPStandardImplementation::deleteMembers(){ //filter deleteFilter(); for(int i=0; igetSemValue(),(void*)(buffer[i])); } delete fifoFree[i]; - fifoFree[i] = NULL; + fifoFree[i] = 0; } if(fifo[i]){ while(!fifo[i]->isEmpty()){ @@ -357,11 +357,11 @@ int UDPStandardImplementation::setupFifoStructure(){ //cprintf(CYAN,"Fifo[%d]: value:%d, pop 0x%x\n",i,fifo[i]->getSemValue(),(void*)(buffer[i])); } delete fifo[i]; - fifo[i] = NULL; + fifo[i] = 0; } - if(mem0[i]){ + if(!mem0[i]){ free(mem0[i]); - mem0[i] = NULL; + mem0[i] = 0; } //creating @@ -370,7 +370,7 @@ int UDPStandardImplementation::setupFifoStructure(){ //allocate memory mem0[i] = (char*)malloc((bufferSize * numberofJobsPerBuffer + fifoBufferHeaderSize) * fifoSize); - if (mem0[i] == NULL){ + if (mem0[i]){ cprintf(BG_RED,"Error: Could not allocate memory for listening \n"); return FAIL; } @@ -633,7 +633,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){ //gui buffer for(int i=0;iShutDownSocket(); FILE_LOG(logINFO) << "Shut down UDP Socket " << i; delete udpSocket[i]; - udpSocket[i] = NULL; + udpSocket[i] = 0; } } return OK; @@ -1178,7 +1178,7 @@ void UDPStandardImplementation::closeFile(int ithread){ FILE_LOG(logDEBUG4) << "Going to close file: " << fileno(sfilefd)); #endif fclose(sfilefd[ithread]); - sfilefd[ithread] = NULL; + sfilefd[ithread] = 0; } } @@ -1190,7 +1190,7 @@ void UDPStandardImplementation::closeFile(int ithread){ FILE_LOG(logDEBUG4) << "sfilefd: " << (int)sfilefd[i]; #endif fclose(sfilefd[0]); - sfilefd[0] = NULL; + sfilefd[0] = 0; } #endif @@ -1211,10 +1211,10 @@ void UDPStandardImplementation::closeFile(int ithread){ //close file if(myTree[ithread] && myFile[ithread]) myFile[ithread] = myTree[ithread]->GetCurrentFile(); - if(myFile[ithread] != NULL) + if(myFile[ithread] != 0) myFile[ithread]->Close(); - myFile[ithread] = NULL; - myTree[ithread] = NULL; + myFile[ithread] = 0; + myTree[ithread] = 0; pthread_mutex_unlock(&writeMutex); #endif @@ -1554,17 +1554,19 @@ int UDPStandardImplementation::createNewFile(int ithread){ //close file pointers if(sfilefd[ithread]){ fclose(sfilefd[ithread]); - sfilefd[ithread] = NULL; + sfilefd[ithread] = 0; } //create file if(!overwriteEnable){ if (NULL == (sfilefd[ithread] = fopen((const char *) (completeFileName[ithread]), "wx"))){ FILE_LOG(logERROR) << "Could not create/overwrite file" << completeFileName[ithread]; + sfilefd[ithread] = 0; return FAIL; } }else if (NULL == (sfilefd[ithread] = fopen((const char *) (completeFileName[ithread]), "w"))){ FILE_LOG(logERROR) << "Could not create file" << completeFileName[ithread]; + sfilefd[ithread] = 0; return FAIL; } //setting file buffer size to 16mb @@ -1961,7 +1963,7 @@ void UDPStandardImplementation::startListening(){ uint32_t rc; //size of buffer received in bytes //split frames for data compression int carryonBufferSize; //from previous buffer to keep frames together in a buffer - char* tempBuffer = NULL; //temporary buffer to store split frames + char* tempBuffer = 0; //temporary buffer to store split frames /* outer loop - loops once for each acquisition */ @@ -1971,7 +1973,7 @@ void UDPStandardImplementation::startListening(){ //compression variables reset before acquisition carryonBufferSize = 0; if(dataCompressionEnable){ - if(tempBuffer!=NULL){delete []tempBuffer;tempBuffer=NULL;} + if(tempBuffer){delete []tempBuffer;tempBuffer=0;} tempBuffer = new char[onePacketSize * (packetsPerFrame - 1)]; //store maximum of 1 packets less in a frame } @@ -1996,7 +1998,7 @@ void UDPStandardImplementation::startListening(){ //udpsocket doesnt exist - if(activated && udpSocket[ithread] == NULL){ + if(activated && !udpSocket[ithread]){ FILE_LOG(logERROR) << "Listening_Thread " << ithread << ": UDP Socket not created or shut down earlier"; stopListening(ithread,0); continue; @@ -2523,7 +2525,7 @@ void UDPStandardImplementation::startWriting(){ //variable definitions char* wbuf; //buffer popped from FIFO - sfilefd[ithread] = NULL; //file pointer + sfilefd[ithread] = 0; //file pointer uint64_t nf; //for compression, number of frames int listenfifoIndex = ithread;