summaryrefslogtreecommitdiff
path: root/main/php.h
diff options
context:
space:
mode:
Diffstat (limited to 'main/php.h')
-rw-r--r--main/php.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/main/php.h b/main/php.h
index 8b6b9dd11b..727e789f76 100644
--- a/main/php.h
+++ b/main/php.h
@@ -97,6 +97,27 @@ extern unsigned char second_arg_allow_ref[];
#include <alloca.h>
#endif
+/*
+ * This is a fast version of strlcpy which should be used, if you
+ * know the maximum size of the destination buffer and if you know
+ * the length of the source string.
+ *
+ * size is the allocated number of bytes
+ * src_size is the number of bytes excluding the NUL
+ */
+
+#define PHP_STRLCPY(dst, src, size, src_size) \
+ { \
+ size_t php_str_len; \
+ \
+ if (src_size >= size) \
+ php_str_len = size - 1; \
+ else \
+ php_str_len = src_size; \
+ memcpy(dst, src, php_str_len); \
+ dst[php_str_len] = '\0'; \
+ }
+
#ifndef HAVE_STRLCPY
PHPAPI size_t strlcpy(char *dst, const char *src, size_t siz);
#endif