diff options
author | Stéphane Desneux <stephane.desneux@iot.bzh> | 2019-10-17 13:41:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@automotivelinux.org> | 2019-10-17 13:41:13 +0000 |
commit | 9d23e5814b651a980bc20c0e9a45f43f36ec3926 (patch) | |
tree | efa98f52a1dc013a72ed9860fc61916dc5e41fa1 | |
parent | a45ec9e85415bbc24f3950cf5a41cfc69bce30b9 (diff) | |
parent | 6baf3d19cfb593359d951c4353a48910802f73a2 (diff) |
Merge "Add a function to delete all hal api"
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-api-loader.c | 39 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-api-loader.h | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.c b/src/4a-internals-hal/4a-internals-hal-api-loader.c index a8b62c6..b41c7b2 100644 --- a/src/4a-internals-hal/4a-internals-hal-api-loader.c +++ b/src/4a-internals-hal/4a-internals-hal-api-loader.c @@ -291,4 +291,43 @@ int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) } return 0; +} + +int InternalHalDeleteAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) +{ + int err; + + char *toDeleteApiName; + + struct HalData *currentHalData; + + if(! apiHandle || ! halMgrData) { + AFB_API_ERROR(apiHandle, "Invalid argument(s)"); + return -1; + } + + cds_list_for_each_entry(currentHalData, &halMgrData->halDataListHead, node) { + if(! currentHalData->apiName) + return -2; + + toDeleteApiName = strdup(currentHalData->apiName); + if(! toDeleteApiName) { + AFB_API_ERROR(apiHandle, "Didn't succeed to store (allocate) 'apiName' string"); + return -3; + } + + err = InternalHalDeleteApi(apiHandle, &halMgrData->halDataListHead, currentHalData); + if(err) { + AFB_API_ERROR(apiHandle, + "Error %i happened when tried to delete %s api", + err, + toDeleteApiName); + free(toDeleteApiName); + return -4; + } + + free(toDeleteApiName); + } + + return 0; }
\ No newline at end of file diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.h b/src/4a-internals-hal/4a-internals-hal-api-loader.h index 1628e8a..2a47555 100644 --- a/src/4a-internals-hal/4a-internals-hal-api-loader.h +++ b/src/4a-internals-hal/4a-internals-hal-api-loader.h @@ -28,5 +28,6 @@ int InternalHalCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *halMgrData); int InternalHalDeleteApi(afb_api_t apiHandle, struct cds_list_head *halDataListHead, struct HalData *toDeleteHalData); int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData); +int InternalHalDeleteAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData); #endif /* _INTERNALS_HAL_API_LOADER_INCLUDE_ */
\ No newline at end of file |