mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-22 04:05:31 -04:00
universal7885: parts-aidl: Just use new operator
Using std::unique_ptr may result in deleted pointer
This commit is contained in:
parent
7f099b9e43
commit
06c69bfd89
1 changed files with 4 additions and 4 deletions
|
|
@ -17,11 +17,10 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace aidl::vendor::eureka::hardware::parts {
|
namespace aidl::vendor::eureka::hardware::parts {
|
||||||
|
|
||||||
static std::unique_ptr<SmartChargeImpl> kInst;
|
static SmartChargeImpl *kInst;
|
||||||
|
|
||||||
static int limit = 0;
|
static int limit = 0;
|
||||||
static int restart = 0;
|
static int restart = 0;
|
||||||
|
|
@ -33,7 +32,7 @@ static int restart_stat = 0;
|
||||||
if (limit == 0 || restart == 0)
|
if (limit == 0 || restart == 0)
|
||||||
return ::ndk::ScopedAStatus::fromExceptionCodeWithMessage(
|
return ::ndk::ScopedAStatus::fromExceptionCodeWithMessage(
|
||||||
EX_ILLEGAL_ARGUMENT, "Start called without configuring.");
|
EX_ILLEGAL_ARGUMENT, "Start called without configuring.");
|
||||||
kInst = std::make_unique<SmartChargeImpl>(limit, restart);
|
kInst = new SmartChargeImpl(limit, restart);
|
||||||
kInst->start();
|
kInst->start();
|
||||||
return ::ndk::ScopedAStatus::ok();
|
return ::ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +42,8 @@ static int restart_stat = 0;
|
||||||
kInst->stop();
|
kInst->stop();
|
||||||
limit_stat += kInst->charge_limit_cnt;
|
limit_stat += kInst->charge_limit_cnt;
|
||||||
restart_stat += kInst->restart_cnt;
|
restart_stat += kInst->restart_cnt;
|
||||||
kInst.reset();
|
delete kInst;
|
||||||
|
kInst = nullptr;
|
||||||
}
|
}
|
||||||
return ::ndk::ScopedAStatus::ok();
|
return ::ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue