Changes in getters functions for security manager policy entries 53/35253/3
authorSebastian Grabowski <s.grabowski@samsung.com>
Wed, 11 Feb 2015 08:31:28 +0000 (09:31 +0100)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 27 Feb 2015 16:27:14 +0000 (08:27 -0800)
In order to get rid of resources duplication strdup has been removed
from functions that get values from a struct policy_entry. So no longer
any additional free is required after using security_manager_policy_entry_get
family functions.

Change-Id: I8070dcd098f9049082da08cb4a640d70a127e5e1
Signed-off-by: Sebastian Grabowski <s.grabowski@samsung.com>
src/client/client-security-manager.cpp
src/include/security-manager.h

index 87b0a74..56d4f23 100644 (file)
@@ -859,44 +859,29 @@ int security_manager_policy_update_req_add_entry(policy_update_req *p_req, const
 SECURITY_MANAGER_API
 const char *security_manager_policy_entry_get_user(policy_entry *p_entry)
 {
-    if (p_entry)
-        return strdup(p_entry->user.c_str());
-    else
-        return nullptr;
+    return p_entry ? p_entry->user.c_str() : nullptr;
 }
 
 SECURITY_MANAGER_API
 const char *security_manager_policy_entry_get_application(policy_entry *p_entry)
 {
-    if (p_entry)
-        return strdup(p_entry->appId.c_str());
-    else
-        return nullptr;
+    return p_entry ? p_entry->appId.c_str() : nullptr;
 }
 SECURITY_MANAGER_API
 const char *security_manager_policy_entry_get_privilege(policy_entry *p_entry)
 {
-    if (p_entry)
-        return strdup(p_entry->privilege.c_str());
-    else
-        return nullptr;
+    return p_entry ? p_entry->privilege.c_str() : nullptr;
 }
 SECURITY_MANAGER_API
 const char *security_manager_policy_entry_get_level(policy_entry *p_entry)
 {
-    if (p_entry)
-        return strdup(p_entry->currentLevel.c_str());
-    else
-        return nullptr;
+    return p_entry ? p_entry->currentLevel.c_str() : nullptr;
 }
 
 SECURITY_MANAGER_API
 const char *security_manager_policy_entry_get_max_level(policy_entry *p_entry)
 {
-    if (p_entry)
-        return strdup(p_entry->maxLevel.c_str());
-    else
-        return nullptr;
+    return p_entry ? p_entry->maxLevel.c_str() : nullptr;
 }
 
 SECURITY_MANAGER_API
index d04ca67..daa06de 100644 (file)
@@ -494,7 +494,7 @@ int security_manager_policy_update_req_add_entry(policy_update_req *p_req, const
  * This function is used to obtain user ID from p_entry structure
  *
  * \param[in] p_entry Pointer handling policy_entry structure
- * \attention Warning: memory pointed to by value written to policy_level needs to be freed
+ * \attention Warning: returned pointer to user ID is valid as long as p_entry is valid.
  *
  * \return user uid
  */
@@ -504,7 +504,7 @@ const char *security_manager_policy_entry_get_user(policy_entry *p_entry);
  * This function is used to obtain application name from p_entry structure
  *
  * \param[in] p_entry Pointer handling policy_entry structure
- * \attention Warning: memory pointed to by value written to policy_level needs to be freed
+ * \attention Warning: returned pointer to application name is valid as long as p_entry is valid.
  *
  * \return application name
  */
@@ -514,7 +514,7 @@ const char *security_manager_policy_entry_get_application(policy_entry *p_entry)
  * This function is used to obtain privilege name from p_entry structure
  *
  * \param[in] p_entry Pointer handling policy_entry structure
- * \attention Warning: memory pointed to by value written to policy_level needs to be freed
+ * \attention Warning: returned pointer to privilege name is valid as long as p_entry is valid.
  *
  * \return privilege name
  */
@@ -523,7 +523,7 @@ const char *security_manager_policy_entry_get_privilege(policy_entry *p_entry);
  * This function is used to obtain current policy level from p_entry structure
  *
  * \param[in] p_entry Pointer handling policy_entry structure
- * \attention Warning: memory pointed to by value written to policy_level needs to be freed
+ * \attention Warning: returned pointer to policy level is valid as long as p_entry is valid.
  *
  * \return Current policy level
  */
@@ -533,7 +533,7 @@ const char *security_manager_policy_entry_get_level(policy_entry *p_entry);
  * This function is used to obtain maximal policy level from p_entry structure
  *
  * \param[in] p_entry Pointer handling policy_entry structure.
- * \attention Warning: memory pointed to by value written to policy_level needs to be freed
+ * \attention Warning: returned pointer to maximal policy level is valid as long as p_entry is valid.
  *
  * \return Maximal policy level
  */