- code format updates and additional NULL pointer checks in map.c

v1.6_develop_528
Michael Zillgith 5 days ago
parent 4d7d31e2a6
commit 0cb094b056

@ -1,7 +1,7 @@
/* /*
* map.c * map.c
* *
* Copyright 2013 Michael Zillgith * Copyright 2013-2025 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -43,8 +43,13 @@ Map
Map_create() Map_create()
{ {
Map map = (Map) GLOBAL_CALLOC(1, sizeof(struct sMap)); Map map = (Map) GLOBAL_CALLOC(1, sizeof(struct sMap));
if (map)
{
map->entries = LinkedList_create(); map->entries = LinkedList_create();
map->compareKeys = comparePointerKeys; map->compareKeys = comparePointerKeys;
}
return map; return map;
} }
@ -58,12 +63,20 @@ void*
Map_addEntry(Map map, void* key, void* value) Map_addEntry(Map map, void* key, void* value)
{ {
MapEntry* entry = (MapEntry*) GLOBAL_MALLOC(sizeof(MapEntry)); MapEntry* entry = (MapEntry*) GLOBAL_MALLOC(sizeof(MapEntry));
if (entry)
{
entry->key = key; entry->key = key;
entry->value = value; entry->value = value;
LinkedList_add(map->entries, entry); LinkedList_add(map->entries, entry);
return entry->key; return entry->key;
} }
else
{
return NULL;
}
}
void* void*
Map_removeEntry(Map map, void* key, bool deleteKey) Map_removeEntry(Map map, void* key, bool deleteKey)

@ -2877,7 +2877,6 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, const char* variableId, int
/* Report control blocks - BR, RP */ /* Report control blocks - BR, RP */
if (isReportControlBlock(separator)) if (isReportControlBlock(separator))
{ {
char* reportName = MmsMapping_getNextNameElement(separator + 1); char* reportName = MmsMapping_getNextNameElement(separator + 1);
if (reportName == NULL) if (reportName == NULL)
@ -2900,7 +2899,6 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, const char* variableId, int
if (rc->domain == domain) if (rc->domain == domain)
{ {
int parentLNNameStrLen = strlen(rc->parentLN->name); int parentLNNameStrLen = strlen(rc->parentLN->name);
if (parentLNNameStrLen != lnNameLength) if (parentLNNameStrLen != lnNameLength)
@ -2913,7 +2911,6 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, const char* variableId, int
if (rcNameLen == variableIdLen) if (rcNameLen == variableIdLen)
{ {
if (strncmp(variableId, rc->name, variableIdLen) == 0) if (strncmp(variableId, rc->name, variableIdLen) == 0)
{ {
const char* elementName = variableId + rcNameLen + 1; const char* elementName = variableId + rcNameLen + 1;

Loading…
Cancel
Save