summaryrefslogtreecommitdiff
path: root/src/port/snprintf.c
diff options
context:
space:
mode:
authorAndres Freund2017-10-09 22:20:42 +0000
committerAndres Freund2017-10-09 22:20:42 +0000
commit8a241792f968ed5be6cf4d41e32c0d264f6c0c65 (patch)
tree80391a1d37c432548e50d07a58a484278c202f74 /src/port/snprintf.c
parent71c75ddfbb277362bf62dc5b1645c3903e16bc34 (diff)
Add pg_strnlen() a portable implementation of strlen.
As the OS version is likely going to be more optimized, fall back to it if available, as detected by configure.
Diffstat (limited to 'src/port/snprintf.c')
-rw-r--r--src/port/snprintf.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 231e5d6bdb4..531d2c5ee35 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -43,6 +43,8 @@
#endif
#include <sys/param.h>
+#include "common/string.h"
+
#ifndef NL_ARGMAX
#define NL_ARGMAX 16
#endif
@@ -790,16 +792,6 @@ bad_format:
target->failed = true;
}
-static size_t
-pg_strnlen(const char *str, size_t maxlen)
-{
- const char *p = str;
-
- while (maxlen-- > 0 && *p)
- p++;
- return p - str;
-}
-
static void
fmtstr(char *value, int leftjust, int minlen, int maxwidth,
int pointflag, PrintfTarget *target)