1 /* 2 * Copyright (c) 2025 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 XPERF_EVENT_H 17 #define XPERF_EVENT_H 18 19 #include <string> 20 #include "hisysevent_c.h" 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 struct XperfEvent { 25 std::string evtName; 26 HiSysEventEventType evtType{HISYSEVENT_BEHAVIOR}; 27 HiSysEventParam* params{nullptr}; 28 int paramSize{0}; 29 XperfEventXperfEvent30 XperfEvent() 31 { 32 } 33 XperfEventXperfEvent34 XperfEvent(const std::string& name, const HiSysEventEventType& type, const int& size) 35 { 36 evtName = name; 37 evtType = type; 38 paramSize = size; 39 params = new HiSysEventParam[paramSize]; 40 } 41 ~XperfEventXperfEvent42 ~XperfEvent() 43 { 44 for (int i = 0; i < paramSize; i++) { 45 if ((params[i].t == HISYSEVENT_STRING) && (params[i].v.s != nullptr)) { 46 delete[] params[i].v.s; 47 params[i].v.s = nullptr; 48 } 49 } 50 if (params != nullptr) { 51 delete[] params; 52 params = nullptr; 53 } 54 } 55 }; 56 } // HiviewDFX 57 } // OHOS 58 #endif //XPERF_EVENT_H