merging refactor (replacing)

This commit is contained in:
2019-04-12 10:53:09 +02:00
parent 0bb800cc8a
commit 89a06f099c
1176 changed files with 82698 additions and 159058 deletions

30
slsReceiverSoftware/src/Fifo.cpp Normal file → Executable file
View File

@ -6,6 +6,7 @@
***********************************************/
#include "Fifo.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <cstdlib>
@ -14,29 +15,28 @@
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
index(ind),
memory(0),
fifoBound(0),
fifoFree(0),
fifoStream(0),
memory(nullptr),
fifoBound(nullptr),
fifoFree(nullptr),
fifoStream(nullptr),
fifoDepth(depth),
status_fifoBound(0),
status_fifoFree(depth){
FILE_LOG(logDEBUG) << __AT__ << " called";
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(CreateFifos(fifoItemSize) == FAIL)
throw std::exception();
throw sls::RuntimeError("Could not create FIFO");
}
Fifo::~Fifo() {
FILE_LOG(logDEBUG) << __AT__ << " called";
//cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
DestroyFifos();
}
int Fifo::CreateFifos(uint32_t fifoItemSize) {
FILE_LOG(logDEBUG) << __AT__ << " called";
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
//destroy if not already
DestroyFifos();
@ -48,7 +48,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
//allocate memory
size_t mem_len = fifoItemSize * fifoDepth * sizeof(char);
memory = (char*) malloc (mem_len);
if (memory == NULL){
if (memory == nullptr){
FILE_LOG(logERROR) << "Could not allocate memory for fifos";
return FAIL;
}
@ -69,23 +69,23 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
void Fifo::DestroyFifos(){
FILE_LOG(logDEBUG) << __AT__ << " called";
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(memory) {
free(memory);
memory = 0;
memory = nullptr;
}
if (fifoBound) {
delete fifoBound;
fifoBound = 0;
fifoBound = nullptr;
}
if (fifoFree) {
delete fifoFree;
fifoFree = 0;
fifoFree = nullptr;
}
if (fifoStream) {
delete fifoStream;
fifoStream = 0;
fifoStream = nullptr;
}
}