- removed remaining calls to malloc, calloc, free. Replaced by GLOBAL_.. macros.

pull/6/head
Michael Zillgith 11 years ago
parent 5bc9834b74
commit 1450d84eaf

@ -197,15 +197,15 @@ initialize(ControlObject* self)
printf("No control model found for variable %s\n", ctlModelName); printf("No control model found for variable %s\n", ctlModelName);
} }
free(ctlModelName); GLOBAL_FREEMEM(ctlModelName);
char* sboClassName = createString(4, self->lnName, "$CF$", self->name, "$sboClass"); char* sboClassName = createString(4, self->lnName, "$CF$", self->name, "$sboClass");
self->sboClass = MmsServer_getValueFromCache(mmsServer, self->mmsDomain, sboClassName); self->sboClass = MmsServer_getValueFromCache(mmsServer, self->mmsDomain, sboClassName);
free(sboClassName); GLOBAL_FREEMEM(sboClassName);
self->ctlObjectName = (char*) malloc(130); self->ctlObjectName = (char*) GLOBAL_MALLOC(130);
createStringInBuffer(self->ctlObjectName, 5, MmsDomain_getName(self->mmsDomain), "/", createStringInBuffer(self->ctlObjectName, 5, MmsDomain_getName(self->mmsDomain), "/",
self->lnName, "$CO$", self->name); self->lnName, "$CO$", self->name);
@ -239,8 +239,8 @@ initialize(ControlObject* self)
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("timeout for %s is %i\n", sboTimeoutName, self->selectTimeout); printf("timeout for %s is %i\n", sboTimeoutName, self->selectTimeout);
free(controlObjectReference); GLOBAL_FREEMEM(controlObjectReference);
free(sboTimeoutName); GLOBAL_FREEMEM(sboTimeoutName);
} }
else { else {
self->sbo = MmsValue_newVisibleString(NULL); self->sbo = MmsValue_newVisibleString(NULL);
@ -475,7 +475,7 @@ ControlObject_destroy(ControlObject* self)
MmsValue_delete(self->emptyString); MmsValue_delete(self->emptyString);
if (self->ctlObjectName != NULL) if (self->ctlObjectName != NULL)
free(self->ctlObjectName); GLOBAL_FREEMEM(self->ctlObjectName);
if (self->error != NULL) if (self->error != NULL)
MmsValue_delete(self->error); MmsValue_delete(self->error);
@ -493,14 +493,14 @@ ControlObject_destroy(ControlObject* self)
MmsValue_delete(self->origin); MmsValue_delete(self->origin);
if (self->name != NULL) if (self->name != NULL)
free(self->name); GLOBAL_FREEMEM(self->name);
#if (CONFIG_MMS_THREADLESS_STACK != 1) #if (CONFIG_MMS_THREADLESS_STACK != 1)
if (self->stateLock != NULL) if (self->stateLock != NULL)
Semaphore_destroy(self->stateLock); Semaphore_destroy(self->stateLock);
#endif #endif
free(self); GLOBAL_FREEMEM(self);
} }
void void
@ -1214,10 +1214,10 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("IED_SERVER: writeAccessControlObject: %s\n", variableIdOrig); printf("IED_SERVER: writeAccessControlObject: %s\n", variableIdOrig);
char variableId[129]; char variableId[65];
strncpy(variableId, variableIdOrig, 128); strncpy(variableId, variableIdOrig, 64);
variableId[128] = 0; variableId[64] = 0;
char* separator = strchr(variableId, '$'); char* separator = strchr(variableId, '$');

@ -299,7 +299,7 @@ mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* doma
ReadRequest_t* readRequest = createReadRequest(mmsPdu); ReadRequest_t* readRequest = createReadRequest(mmsPdu);
if (specWithResult) { if (specWithResult) {
readRequest->specificationWithResult = (BOOLEAN_t*) calloc(1, sizeof(BOOLEAN_t)); readRequest->specificationWithResult = (BOOLEAN_t*) GLOBAL_CALLOC(1, sizeof(BOOLEAN_t));
(*(readRequest->specificationWithResult)) = true; (*(readRequest->specificationWithResult)) = true;
} }
else else
@ -339,7 +339,7 @@ mmsClient_createReadAssociationSpecificNamedVariableListRequest(
ReadRequest_t* readRequest = createReadRequest(mmsPdu); ReadRequest_t* readRequest = createReadRequest(mmsPdu);
if (specWithResult) { if (specWithResult) {
readRequest->specificationWithResult = (BOOLEAN_t*) calloc(1, sizeof(BOOLEAN_t)); readRequest->specificationWithResult = (BOOLEAN_t*) GLOBAL_CALLOC(1, sizeof(BOOLEAN_t));
(*(readRequest->specificationWithResult)) = true; (*(readRequest->specificationWithResult)) = true;
} }
else else

@ -176,8 +176,6 @@ createNewDomainVariableSpecification(const char* domainId, const char* itemId)
{ {
VariableSpecification_t* varSpec = (VariableSpecification_t*) GLOBAL_CALLOC(1, sizeof(ListOfVariableSeq_t)); VariableSpecification_t* varSpec = (VariableSpecification_t*) GLOBAL_CALLOC(1, sizeof(ListOfVariableSeq_t));
//VariableSpecification_t* varSpec = (VariableSpecification_t*) calloc(1, sizeof(VariableSpecification_t));
varSpec->present = VariableSpecification_PR_name; varSpec->present = VariableSpecification_PR_name;
varSpec->choice.name.present = ObjectName_PR_domainspecific; varSpec->choice.name.present = ObjectName_PR_domainspecific;
varSpec->choice.name.choice.domainspecific.domainId.buf = (uint8_t*) domainId; varSpec->choice.name.choice.domainspecific.domainId.buf = (uint8_t*) domainId;
@ -191,10 +189,8 @@ createNewDomainVariableSpecification(const char* domainId, const char* itemId)
static void static void
deleteDataElement(Data_t* dataElement) deleteDataElement(Data_t* dataElement)
{ {
if (dataElement == NULL ) { if (dataElement == NULL)
printf("deleteDataElement NULL argument\n");
return; return;
}
if (dataElement->present == Data_PR_structure) { if (dataElement->present == Data_PR_structure) {
int elementCount = dataElement->choice.structure->list.count; int elementCount = dataElement->choice.structure->list.count;

@ -51,7 +51,7 @@ MmsDevice_destroy(MmsDevice* self)
MmsVariableSpecification_destroy(self->namedVariables[i]); MmsVariableSpecification_destroy(self->namedVariables[i]);
} }
free (self->namedVariables); GLOBAL_FREEMEM(self->namedVariables);
} }
#endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */ #endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */

@ -526,7 +526,7 @@ IsoServer_waitReady(IsoServer self, unsigned int timeoutMs)
} else { } else {
IsoConnection_destroy(isoConnection); IsoConnection_destroy(isoConnection);
lastConnection->next = openConnection->next; lastConnection->next = openConnection->next;
free(openConnection); GLOBAL_FREEMEM(openConnection);
openConnection = lastConnection->next; openConnection = lastConnection->next;
} }

Loading…
Cancel
Save