mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-24 10:31:09 +02:00
check empty instead of strcmp
This commit is contained in:
@ -41,13 +41,12 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify)
|
|||||||
* so sls shared memory will be created */
|
* so sls shared memory will be created */
|
||||||
|
|
||||||
// ensure shared memory was not created before
|
// ensure shared memory was not created before
|
||||||
SharedMemory* shm = new SharedMemory(multiId, id);
|
auto shm = SharedMemory(multiId, id);
|
||||||
if (shm->IsExisting()) {
|
if (shm.IsExisting()) {
|
||||||
cprintf(YELLOW BOLD,"Warning: Weird, this shared memory should have been "
|
cprintf(YELLOW BOLD,"Warning: Weird, this shared memory should have been "
|
||||||
"deleted before! %s. Freeing it again.\n", shm->GetName().c_str());
|
"deleted before! %s. Freeing it again.\n", shm.GetName().c_str());
|
||||||
freeSharedMemory(multiId, id);
|
freeSharedMemory(multiId, id);
|
||||||
}
|
}
|
||||||
delete shm;
|
|
||||||
|
|
||||||
initSharedMemory(true, type, multiId, verify);
|
initSharedMemory(true, type, multiId, verify);
|
||||||
initializeDetectorStructure(type);
|
initializeDetectorStructure(type);
|
||||||
@ -262,9 +261,8 @@ int64_t slsDetector::getId( idMode mode) {
|
|||||||
|
|
||||||
|
|
||||||
void slsDetector::freeSharedMemory(int multiId, int slsId) {
|
void slsDetector::freeSharedMemory(int multiId, int slsId) {
|
||||||
SharedMemory* shm = new SharedMemory(multiId, slsId);
|
auto shm = SharedMemory(multiId, slsId);
|
||||||
shm->RemoveSharedMemory();
|
shm.RemoveSharedMemory();
|
||||||
delete shm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsDetector::freeSharedMemory() {
|
void slsDetector::freeSharedMemory() {
|
||||||
@ -1156,8 +1154,26 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
|
|||||||
char thisName[MAX_STR_LENGTH];
|
char thisName[MAX_STR_LENGTH];
|
||||||
int thisCP, thisSP;
|
int thisCP, thisSP;
|
||||||
int retval=OK;
|
int retval=OK;
|
||||||
|
// if (strcmp(name.c_str(),"")!=0) {
|
||||||
|
// #ifdef VERBOSE
|
||||||
|
// std::cout<< "setting hostname" << std::endl;
|
||||||
|
// #endif
|
||||||
|
// strcpy(thisName,name.c_str());
|
||||||
|
// strcpy(thisDetector->hostname,thisName);
|
||||||
|
// if (controlSocket) {
|
||||||
|
// delete controlSocket;
|
||||||
|
// controlSocket=0;
|
||||||
|
// }
|
||||||
|
// if (stopSocket) {
|
||||||
|
// delete stopSocket;
|
||||||
|
// stopSocket=0;
|
||||||
|
// }
|
||||||
|
// } else
|
||||||
|
// strcpy(thisName,thisDetector->hostname);
|
||||||
|
|
||||||
if (strcmp(name.c_str(),"")!=0) {
|
if (name.empty()){
|
||||||
|
strcpy(thisName,thisDetector->hostname);
|
||||||
|
}else{
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "setting hostname" << std::endl;
|
std::cout<< "setting hostname" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -1171,8 +1187,8 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
|
|||||||
delete stopSocket;
|
delete stopSocket;
|
||||||
stopSocket=0;
|
stopSocket=0;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
strcpy(thisName,thisDetector->hostname);
|
|
||||||
|
|
||||||
if (control_port>0) {
|
if (control_port>0) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
Reference in New Issue
Block a user