From: mk5004.lee Date: Mon, 9 Mar 2020 08:24:14 +0000 (+0900) Subject: Change to dynamic allocation from static X-Git-Tag: submit/tizen_5.5/20200311.053658^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c0ded586a9013fdcfb8f63b04cb64fd343c5ef1;p=platform%2Fcore%2Fapi%2Fnotification.git Change to dynamic allocation from static Change-Id: Ie3cb8faef52d566a25074db9b78d41a49f740e2c Signed-off-by: mk5004.lee --- diff --git a/notification-ex/stub.cc b/notification-ex/stub.cc old mode 100644 new mode 100755 index 66b18bec..0478bc38 --- a/notification-ex/stub.cc +++ b/notification-ex/stub.cc @@ -3154,6 +3154,8 @@ extern "C" EXPORT_API int noti_ex_reporter_find_by_channel(noti_ex_reporter_h ha return NOTI_EX_ERROR_INVALID_PARAMETER; } + Handle** list_item = nullptr; + try { ReporterStub* stub = static_cast(handle); list> list_ptr = stub->FindByChannel(channel); @@ -3166,7 +3168,7 @@ extern "C" EXPORT_API int noti_ex_reporter_find_by_channel(noti_ex_reporter_h ha int size = list_ptr.size(); int i = 0; - Handle* list_item[size]; + list_item = (Handle**)calloc(size, sizeof(Handle*)); for (auto& ptr : list_ptr) list_item[i++] = new Handle(std::move(ptr)); @@ -3174,6 +3176,7 @@ extern "C" EXPORT_API int noti_ex_reporter_find_by_channel(noti_ex_reporter_h ha *count = size; } catch (Exception &ex) { LOGE("%s %d", ex.what(), ex.GetErrorCode()); + free(list_item); return NOTI_EX_ERROR_IO_ERROR; } @@ -3187,6 +3190,8 @@ extern "C" EXPORT_API int noti_ex_reporter_find_all(noti_ex_reporter_h handle, return NOTI_EX_ERROR_INVALID_PARAMETER; } + Handle** list_item = nullptr; + try { ReporterStub* stub = static_cast(handle); list> list_ptr = stub->FindAll(); @@ -3199,7 +3204,7 @@ extern "C" EXPORT_API int noti_ex_reporter_find_all(noti_ex_reporter_h handle, int size = list_ptr.size(); int i = 0; - Handle* list_item[size]; + list_item = (Handle**)calloc(size, sizeof(Handle*)); for (auto& ptr : list_ptr) list_item[i++] = new Handle(std::move(ptr)); @@ -3207,6 +3212,7 @@ extern "C" EXPORT_API int noti_ex_reporter_find_all(noti_ex_reporter_h handle, *count = size; } catch (Exception &ex) { LOGE("%s %d", ex.what(), ex.GetErrorCode()); + free(list_item); return NOTI_EX_ERROR_IO_ERROR; }