Sorry for the delay.

You should probably use the same doxygen header in both the .h and .c files, with the @param lines.


--

Rebecca Cran


On 11/3/21 2:44 AM, mateusz.mo...@intel.com wrote:
From: mateusz-mowka <mateusz.mo...@intel.com>

This patch adds strnlen function wrapper that internally calls
AsciiStrnLenS, which is defined in BaseLib.

Cc: Caleb Reister <caleb.reis...@intel.com>
Cc: Rebecca Cran <rebe...@nuviainc.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>

Signed-off-by: Mateusz Mówka <mateusz.mo...@intel.com>
---
  StdLib/Include/string.h   | 11 +++++++++++
  StdLib/LibC/String/Misc.c | 12 ++++++++++++
  2 files changed, 23 insertions(+)

diff --git a/StdLib/Include/string.h b/StdLib/Include/string.h
index 0c80944..07652ca 100644
--- a/StdLib/Include/string.h
+++ b/StdLib/Include/string.h
@@ -62,6 +62,7 @@
        void     *memset      (void *s, int c, size_t n);
        char     *strerror    (int num);
        size_t    strlen      (const char *);
+      size_t    strnlen     (const char, size_t n)
################ BSD Compatibility Functions
        char     *strdup      (const char *);
@@ -454,6 +455,16 @@ char     *strerror(int Num);
  **/
  size_t    strlen(const char *S);
+/** The strnlen function computes the length of a fixed-size string.
+
+    @param[in]  S   Pointer to the string to determine the length of.
+    @param[in]  N   Length of a string including the terminating character.
+
+    @return   The strnlen function returns the number of characters that
+              precede the terminating null character but not exceeding N.
+**/
+size_t    strnlen(const char *S, size_t N);
+
/* ################ BSD Compatibility Functions ####################### */ diff --git a/StdLib/LibC/String/Misc.c b/StdLib/LibC/String/Misc.c
index f024136..cf680e3 100644
--- a/StdLib/LibC/String/Misc.c
+++ b/StdLib/LibC/String/Misc.c
@@ -99,3 +99,15 @@ strlen(const char *s)
  {
    return (size_t)AsciiStrLen( s);
  }
+
+/** The strnlen function computes the length of the string pointed to by s
+    but at most n
+
+    @return   The strnlen function returns the number of characters that
+              precede the terminating null character but at most n.
+**/
+size_t
+strnlen(const char *s, size_t n)
+{
+  return (size_t)AsciiStrnLenS( s, n);
+}


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84666): https://edk2.groups.io/g/devel/message/84666
Mute This Topic: https://groups.io/mt/86803221/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to