Change to dynamic allocation from static 53/227053/3
authormk5004.lee <mk5004.lee@samsung.com>
Mon, 9 Mar 2020 08:24:14 +0000 (17:24 +0900)
committerMyungKi Lee <mk5004.lee@samsung.com>
Tue, 10 Mar 2020 01:30:58 +0000 (01:30 +0000)
Change-Id: Ie3cb8faef52d566a25074db9b78d41a49f740e2c
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
notification-ex/stub.cc [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 66b18be..0478bc3
@@ -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<ReporterStub*>(handle);
     list<unique_ptr<AbstractItem>> 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<ReporterStub*>(handle);
     list<unique_ptr<AbstractItem>> 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;
   }