录音界面优化:使用memset初始化防止踩内存 1632/4
authorluozheng <1732036298@qq.com>
Thu, 16 Jan 2025 03:53:14 +0000 (11:53 +0800)
committerluozheng <1732036298@qq.com>
Thu, 16 Jan 2025 03:53:14 +0000 (11:53 +0800)
code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp

index e07dc40..dd797c0 100644 (file)
@@ -19,6 +19,7 @@
 #include "uiservice/include/ui_service.h"
 #include "custom_runtime.h"
 #include "vibrator_service.h"
+#include <string.h>
 namespace OHOS
 {
     std::string RecordingModel::recordTempDuration = 0;
@@ -903,7 +904,8 @@ namespace OHOS
         std::string recordingFileName = GetRecordFileName();                  // 录音文件名
         std::string yyymmhhh_date = Getyyyymmhhh_date();                      // 保存录音年月日时间
         std::string TotalRecordDuration = RecordingModel::recordTempDuration; // 录音的总时长
-        recordingInfo = {0};
+        // recordingInfo = {0};
+        memset(&recordingInfo, 0, sizeof(RecordingInfo));
         strncpy_s(recordingInfo.recordingFileName, 32, recordingFileName.c_str(), recordingFileName.length());
         strncpy_s(recordingInfo.recordingDuration, 16, TotalRecordDuration.c_str(), TotalRecordDuration.length());
         strncpy_s(recordingInfo.recordingTime, 16, yyymmhhh_date.c_str(), yyymmhhh_date.length());