From 6054e3c1d4a782e8eead1ffd05f46b764cddc577 Mon Sep 17 00:00:00 2001 From: "zhoumengjie7@huawei.com" Date: Wed, 18 Sep 2024 16:40:23 +0800 Subject: [PATCH 1/2] add annotation Signed-off-by: zhoumengjie7@huawei.com Change-Id: Ic90e5ca6745938b2f89562374fc1e78ad06fdfd9 --- .../cpp/include/purgeable_mem_base.h | 22 +++++++++++++++++-- .../interfaces/kits/c/purgeable_memory.h | 18 +++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/libpurgeablemem/cpp/include/purgeable_mem_base.h b/libpurgeablemem/cpp/include/purgeable_mem_base.h index 1567e85..49b48fc 100644 --- a/libpurgeablemem/cpp/include/purgeable_mem_base.h +++ b/libpurgeablemem/cpp/include/purgeable_mem_base.h @@ -39,6 +39,15 @@ public: * While return true if content recover success. * OS cannot reclaim the memory of the obj's content when this * function return true, until EndRead() is called. + * + * Attension: the return value must be recevied and handled, + * since the visiting of this object with the failure result + * will cause unsuspected result. + * For example: + * if (BeginRead()) { + * // visit this object + * EndRead(); + * } */ bool BeginRead(); @@ -50,13 +59,22 @@ public: void EndRead(); /* - * BeginRead: begin read the PurgeableMem obj. + * BeginRead: begin write the PurgeableMem obj. * Return: return true if the obj's content is present. * If content is purged(no present), system will recover its data, * return false if content is purged and recover failed. * While return true if content recover success. * OS cannot reclaim the memory of the obj's content when this - * function return true, until EndRead() is called. + * function return true, until EndWrite() is called. + * + * Attension: the return value must be recevied and handled, + * since the visiting of this object with the failure result + * will cause unsuspected result. + * For example: + * if (BeginWrite()) { + * // visit this object + * EndWrite(); + * } */ bool BeginWrite(); diff --git a/libpurgeablemem/interfaces/kits/c/purgeable_memory.h b/libpurgeablemem/interfaces/kits/c/purgeable_memory.h index a228044..6d87f51 100644 --- a/libpurgeablemem/interfaces/kits/c/purgeable_memory.h +++ b/libpurgeablemem/interfaces/kits/c/purgeable_memory.h @@ -108,6 +108,15 @@ bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory *purgObj); * OS cannot reclaim the memory of @purgObj's content when this * function return true, until PurgMemEndRead() is called. * + * Attension: the return value must be recevied and handled, + * since the visiting of this object with the failure result + * will cause unsuspected result. + * For example: + * if (OH_PurgeableMemory_BeginRead()) { + * // visit this object + * OH_PurgeableMemory_EndRead(); + * } + * * @since 10 * @version 1.0 */ @@ -138,6 +147,15 @@ void OH_PurgeableMemory_EndRead(OH_PurgeableMemory *purgObj); * OS cannot reclaim the memory of @purgObj's content when this * function return true, until PurgMemEndWrite() is called. * + * Attension: the return value must be recevied and handled, + * since the visiting of this object with the failure result + * will cause unsuspected result. + * For example: + * if (OH_PurgeableMemory_BeginWrite()) { + * // visit this object + * OH_PurgeableMemory_EndWrite(); + * } + * * @since 10 * @version 1.0 */ -- Gitee From 560bbb443910cba6b084cf1bda3d8bfc765e4d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=A2=A6=E6=9D=B0?= Date: Thu, 19 Sep 2024 02:14:12 +0000 Subject: [PATCH 2/2] update libpurgeablemem/cpp/include/purgeable_mem_base.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周梦杰 --- libpurgeablemem/cpp/include/purgeable_mem_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libpurgeablemem/cpp/include/purgeable_mem_base.h b/libpurgeablemem/cpp/include/purgeable_mem_base.h index 49b48fc..7ea386d 100644 --- a/libpurgeablemem/cpp/include/purgeable_mem_base.h +++ b/libpurgeablemem/cpp/include/purgeable_mem_base.h @@ -39,7 +39,7 @@ public: * While return true if content recover success. * OS cannot reclaim the memory of the obj's content when this * function return true, until EndRead() is called. - * + * * Attension: the return value must be recevied and handled, * since the visiting of this object with the failure result * will cause unsuspected result. @@ -66,7 +66,7 @@ public: * While return true if content recover success. * OS cannot reclaim the memory of the obj's content when this * function return true, until EndWrite() is called. - * + * * Attension: the return value must be recevied and handled, * since the visiting of this object with the failure result * will cause unsuspected result. -- Gitee