* @brief Control Api Destroy * * @details * - Control Api Close * * @returns * - CTL_RESULT_SUCCESS * - CTL_RESULT_ERROR_UNINITIALIZED * - CTL_RESULT_ERROR_DEVICE_LOST * - CTL_RESULT_ERROR_INVALID_NULL_HANDLE * + `nullptr == hAPIHandle` * - ::CTL_RESULT_ERROR_UNSUPPORTED_VERSION - "Unsupported version" */
| 170 | * - ::CTL_RESULT_ERROR_UNSUPPORTED_VERSION - "Unsupported version" |
| 171 | */ |
| 172 | ctl_result_t CTL_APICALL |
| 173 | ctlClose( |
| 174 | ctl_api_handle_t hAPIHandle ///< [in][release] Control API implementation handle obtained during init |
| 175 | ///< call |
| 176 | ) |
| 177 | { |
| 178 | ctl_result_t result = CTL_RESULT_ERROR_NOT_INITIALIZED; |
| 179 | |
| 180 | |
| 181 | HINSTANCE hinstLibPtr = GetLoaderHandle(); |
| 182 | |
| 183 | if (NULL != hinstLibPtr) |
| 184 | { |
| 185 | ctl_pfnClose_t pfnClose = (ctl_pfnClose_t)GetProcAddress(hinstLibPtr, "ctlClose"); |
| 186 | if (pfnClose) |
| 187 | { |
| 188 | result = pfnClose(hAPIHandle); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | // special code - only for ctlClose() |
| 193 | // might get CTL_RESULT_SUCCESS_STILL_OPEN_BY_ANOTHER_CALLER |
| 194 | // if its open by another caller do not free the instance handle |
| 195 | if( result == CTL_RESULT_SUCCESS) |
| 196 | { |
| 197 | if (NULL != hinstLib) |
| 198 | { |
| 199 | FreeLibrary(hinstLib); |
| 200 | hinstLib = NULL; |
| 201 | } |
| 202 | } |
| 203 | // set runtime args back to NULL |
| 204 | // no need to free this as it's allocated by caller |
| 205 | pRuntimeArgs = NULL; |
| 206 | return result; |
| 207 | } |
| 208 | |
| 209 | |
| 210 | /** |
nothing calls this directly
no test coverage detected