1 /*
2  * Copyright (c) 2022-2024 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 #include "comm_log.h"
17 #include "softbus_adapter_mem.h"
18 #include "softbus_adapter_hisysevent.h"
19 
SoftbusWriteHisEvt(SoftBusEvtReportMsg * reportMsg)20 int32_t SoftbusWriteHisEvt(SoftBusEvtReportMsg *reportMsg)
21 {
22     (void)reportMsg;
23     return 0;
24 }
25 
SoftbusFreeEvtReportMsg(SoftBusEvtReportMsg * msg)26 void SoftbusFreeEvtReportMsg(SoftBusEvtReportMsg *msg)
27 {
28     if (msg == NULL) {
29         return;
30     }
31 
32     if (msg->paramArray != NULL) {
33         SoftBusFree(msg->paramArray);
34         msg->paramArray = NULL;
35     }
36     SoftBusFree(msg);
37 }
38 
SoftbusCreateEvtReportMsg(int32_t paramNum)39 SoftBusEvtReportMsg *SoftbusCreateEvtReportMsg(int32_t paramNum)
40 {
41     if (paramNum <= SOFTBUS_EVT_PARAM_ZERO || paramNum >= SOFTBUS_EVT_PARAM_BUTT) {
42         COMM_LOGE(COMM_ADAPTER, "param is invalid");
43         return NULL;
44     }
45 
46     SoftBusEvtReportMsg *msg = (SoftBusEvtReportMsg *)SoftBusCalloc(sizeof(SoftBusEvtReportMsg));
47     if (msg == NULL) {
48         COMM_LOGE(COMM_ADAPTER, "report msg is null");
49         return NULL;
50     }
51 
52     msg->paramArray = (SoftBusEvtParam *)SoftBusCalloc(sizeof(SoftBusEvtParam) * paramNum);
53     if (msg->paramArray == NULL) {
54         SoftbusFreeEvtReportMsg(msg);
55         return NULL;
56     }
57     return msg;
58 }
59