diff options
Diffstat (limited to '4a-hal/4a-hal-utilities')
-rw-r--r-- | 4a-hal/4a-hal-utilities/4a-hal-utilities-data.c | 38 | ||||
-rw-r--r-- | 4a-hal/4a-hal-utilities/4a-hal-utilities-data.h | 10 |
2 files changed, 22 insertions, 26 deletions
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c index dafed90..11721f2 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c +++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c @@ -56,7 +56,7 @@ struct SpecificHalData *HalUtlAddHalApiToHalList(struct HalMgrData *HalMgrGlobal currentApi = currentApi->next; } - currentApi->name = NULL; + currentApi->apiName = NULL; currentApi->sndCard = NULL; currentApi->author = NULL; currentApi->version = NULL; @@ -93,8 +93,8 @@ uint8_t HalUtlRemoveSelectedHalFromList(struct HalMgrData *HalMgrGlobalData, str } } - if(matchingApi->name) - free(matchingApi->name); + if(matchingApi->apiName) + free(matchingApi->apiName); if(matchingApi->sndCard) free(matchingApi->sndCard); @@ -147,17 +147,17 @@ uint64_t HalUtlGetNumberOfHalInList(struct HalMgrData *HalMgrGlobalData) return numberOfCtlHal; } -struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *name) +struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *apiName) { struct SpecificHalData *currentApi; - if(! HalMgrGlobalData || ! name) + if(! HalMgrGlobalData || ! apiName) return NULL; currentApi = HalMgrGlobalData->first; while(currentApi) { - if(! strcmp(name, currentApi->name)) + if(! strcmp(apiName, currentApi->apiName)) return currentApi; currentApi = currentApi->next; @@ -170,24 +170,20 @@ struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGl * Hal Manager data handling functions * ******************************************************************************/ -uint8_t HalUtlInitializeHalMgrData(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData, char *name, char *description) +uint8_t HalUtlInitializeHalMgrData(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info) { - if(! apiHandle || ! HalMgrGlobalData || ! name || ! description) + if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info) return -1; - // Allocate name and info strings - HalMgrGlobalData->name = (char *) calloc(strlen(name), sizeof(char)); - if(! HalMgrGlobalData->name) + // Allocate and fill apiName and info strings + HalMgrGlobalData->apiName = strdup(apiName); + if(! HalMgrGlobalData->apiName) return -2; - HalMgrGlobalData->description = (char *) calloc(strlen(description), sizeof(char)); - if(! HalMgrGlobalData->name) + HalMgrGlobalData->info = strdup(info); + if(! HalMgrGlobalData->apiName) return -3; - // Fill HalMgrGlobalData structure - strcpy(HalMgrGlobalData->name, name); - strcpy(HalMgrGlobalData->description, description); - HalMgrGlobalData->apiHandle = apiHandle; return 0; @@ -201,11 +197,11 @@ void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData) if(HalMgrGlobalData->first) HalUtlRemoveAllHalFromList(HalMgrGlobalData); - if(HalMgrGlobalData->name) - free(HalMgrGlobalData->name); + if(HalMgrGlobalData->apiName) + free(HalMgrGlobalData->apiName); - if(HalMgrGlobalData->description) - free(HalMgrGlobalData->description); + if(HalMgrGlobalData->info) + free(HalMgrGlobalData->info); free(HalMgrGlobalData); }
\ No newline at end of file diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h index 3ae16db..ab4c8b3 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h +++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h @@ -33,7 +33,7 @@ enum HalStatus { // Structure to store specific hal (controller or external) data struct SpecificHalData { - char *name; + char *apiName; enum HalStatus status; char *sndCard; char *info; @@ -53,8 +53,8 @@ struct SpecificHalData { // Structure to store hal manager data struct HalMgrData { - char *name; - char *description; + char *apiName; + char *info; afb_dynapi *apiHandle; @@ -66,10 +66,10 @@ struct SpecificHalData *HalUtlAddHalApiToHalList(struct HalMgrData *HalMgrGlobal uint8_t HalUtlRemoveSelectedHalFromList(struct HalMgrData *HalMgrGlobalData, struct SpecificHalData *ApiToRemove); uint64_t HalUtlRemoveAllHalFromList(struct HalMgrData *HalMgrGlobalData); uint64_t HalUtlGetNumberOfHalInList(struct HalMgrData *HalMgrGlobalData); -struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *name); +struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *apiName); // Exported verbs for 'struct HalMgrData' handling -uint8_t HalUtlInitializeHalMgrData(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData, char *name, char *description); +uint8_t HalUtlInitializeHalMgrData(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info); void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData); #endif /* _HAL_UTILITIES_DATA_INCLUDE_ */
\ No newline at end of file |