libxml2/backport-Update-xmlStrlen-to-use-POSIX-ISO-C-strlen.patch
Zhipeng Xie 6a272753c8 backport upstream patches
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
2023-02-27 19:39:37 +08:00

35 lines
848 B
Diff

From 43c97c9c203d9920b21db8b1d5a999eac2fa8d69 Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@gmail.com>
Date: Mon, 21 Feb 2022 09:35:59 -0500
Subject: [PATCH 2/3] Update `xmlStrlen()` to use POSIX / ISO C `strlen()`
This should be faster on a wide range of platforms.
Closes #212
---
xmlstring.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/xmlstring.c b/xmlstring.c
index 5a6875f..281b8a7 100644
--- a/xmlstring.c
+++ b/xmlstring.c
@@ -424,13 +424,7 @@ xmlStrsub(const xmlChar *str, int start, int len) {
int
xmlStrlen(const xmlChar *str) {
- size_t len = 0;
-
- if (str == NULL) return(0);
- while (*str != 0) { /* non input consuming */
- str++;
- len++;
- }
+ size_t len = str ? strlen((const char *)str) : 0;
return(len > INT_MAX ? 0 : len);
}
--
2.27.0