Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / security / step_privilege_compatibility.cc
index dd03728..3c1e37c 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "common/step/security/step_privilege_compatibility.h"
 
-#include <boost/scope_exit.hpp>
-
 #include <pkgmgrinfo_basic.h>
 #include <privilege_manager.h>
 
@@ -70,6 +68,14 @@ std::string GetAPIVersion(manifest_x* m, bool is_web) {
   return api_version;
 }
 
+void FreePrivilegeList(GList* priv) {
+  g_list_free_full(priv, free);
+}
+
+void FreePrivilegeXList(GList* priv) {
+  g_list_free_full(priv, &ci::FreePrivilegeX);
+}
+
 bool TranslatePrivilegesForCompatibility(manifest_x* m) {
   if (!m->api_version) {
     LOG(WARNING) << "Skipping privileges mapping because api-version "
@@ -90,14 +96,19 @@ bool TranslatePrivilegesForCompatibility(manifest_x* m) {
   GList* mapped_web_privileges = nullptr;
   GList* converted_native_privileges = nullptr;
   GList* converted_web_privileges = nullptr;
-  BOOST_SCOPE_EXIT_ALL(&) {
-    g_list_free_full(native_privileges, free);
-    g_list_free_full(web_privileges, free);
-    g_list_free_full(mapped_native_privileges, free);
-    g_list_free_full(mapped_web_privileges, free);
-    g_list_free_full(converted_native_privileges, &ci::FreePrivilegeX);
-    g_list_free_full(converted_web_privileges, &ci::FreePrivilegeX);
-  };
+  std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter1(
+      native_privileges, &::FreePrivilegeList);
+  std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter2(
+      web_privileges, &::FreePrivilegeList);
+  std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter3(
+      mapped_native_privileges, &::FreePrivilegeList);
+  std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter4(
+      mapped_web_privileges, &::FreePrivilegeList);
+  std::unique_ptr<GList, decltype(::FreePrivilegeXList)*> deleter5(
+      converted_native_privileges, &::FreePrivilegeXList);
+  std::unique_ptr<GList, decltype(::FreePrivilegeXList)*> deleter6(
+      converted_web_privileges, &::FreePrivilegeXList);
+
   if (!MapPrivileges(native_privileges, &mapped_native_privileges, false,
                      GetAPIVersion(m, false).c_str()))
     return false;
@@ -189,4 +200,3 @@ Step::Status StepPrivilegeCompatibility::process() {
 
 }  // namespace security
 }  // namespace common_installer
-