1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDI_STRUCT_TOOLKIT_H 17 #define HDI_STRUCT_TOOLKIT_H 18 #ifdef HDI_WPA_INTERFACE_SUPPORT 19 #include "wifi_hdi_wpa_client.h" 20 #include "wifi_hdi_wpa_sta_impl.h" 21 #include "wifi_hdi_wpa_callback.h" 22 #include "wifi_hdi_wpa_ap_impl.h" 23 #include "wifi_hdi_wpa_p2p_impl.h" 24 #include "wifi_hdi_util.h" 25 #include "wifi_common_util.h" 26 #include "hdi_struct_toolkit.h" 27 #include <securec.h> 28 #include <unistd.h> 29 FreeHdiWifiWpaNetworkInfo(HdiWifiWpaNetworkInfo * hdiWifiWpaNetworkInfo)30static void FreeHdiWifiWpaNetworkInfo(HdiWifiWpaNetworkInfo *hdiWifiWpaNetworkInfo) 31 { 32 free(hdiWifiWpaNetworkInfo->ssid); 33 free(hdiWifiWpaNetworkInfo->bssid); 34 free(hdiWifiWpaNetworkInfo->flags); 35 hdiWifiWpaNetworkInfo->ssid = nullptr; 36 hdiWifiWpaNetworkInfo->bssid = nullptr; 37 hdiWifiWpaNetworkInfo->flags = nullptr; 38 hdiWifiWpaNetworkInfo = nullptr; 39 } 40 FreeHdiP2pNetworkInfo(HdiP2pNetworkInfo * hdiP2pNetworkInfo)41static void FreeHdiP2pNetworkInfo(HdiP2pNetworkInfo *hdiP2pNetworkInfo) 42 { 43 free(hdiP2pNetworkInfo->ssid); 44 free(hdiP2pNetworkInfo->bssid); 45 free(hdiP2pNetworkInfo->flags); 46 hdiP2pNetworkInfo->ssid = nullptr; 47 hdiP2pNetworkInfo->bssid = nullptr; 48 hdiP2pNetworkInfo->flags = nullptr; 49 } 50 FreeHdiP2pNetworkList(HdiP2pNetworkList * hdiP2pNetworkList)51static void FreeHdiP2pNetworkList(HdiP2pNetworkList *hdiP2pNetworkList) 52 { 53 for (int i = 0; i < hdiP2pNetworkList->infoNum; i++) { 54 FreeHdiP2pNetworkInfo(&hdiP2pNetworkList->infos[i]); 55 } 56 free(hdiP2pNetworkList->infos); 57 hdiP2pNetworkList->infos = nullptr; 58 hdiP2pNetworkList = nullptr; 59 } 60 FreeHdiP2pDeviceInfo(HdiP2pDeviceInfo * hdiP2pDeviceInfo)61static void FreeHdiP2pDeviceInfo(HdiP2pDeviceInfo *hdiP2pDeviceInfo) 62 { 63 free(hdiP2pDeviceInfo->srcAddress); 64 free(hdiP2pDeviceInfo->p2pDeviceAddress); 65 free(hdiP2pDeviceInfo->primaryDeviceType); 66 free(hdiP2pDeviceInfo->deviceName); 67 free(hdiP2pDeviceInfo->wfdDeviceInfo); 68 free(hdiP2pDeviceInfo->operSsid); 69 hdiP2pDeviceInfo->srcAddress = nullptr; 70 hdiP2pDeviceInfo->p2pDeviceAddress = nullptr; 71 hdiP2pDeviceInfo->primaryDeviceType = nullptr; 72 hdiP2pDeviceInfo->deviceName = nullptr; 73 hdiP2pDeviceInfo->wfdDeviceInfo = nullptr; 74 hdiP2pDeviceInfo->operSsid = nullptr; 75 hdiP2pDeviceInfo = nullptr; 76 } 77 #endif 78 #endif