return (d - dst);
}
+gsize
+rspamd_null_safe_copy (const gchar *src, gsize srclen,
+ gchar *dest, gsize destlen)
+{
+ gsize copied = 0, si = 0, di = 0;
+
+ if (destlen == 0) {
+ return 0;
+ }
+
+ while (si < srclen && di + 1 < destlen) {
+ if (src[si] != '\0') {
+ dest[di++] = src[si++];
+ copied ++;
+ }
+ else {
+ si ++;
+ }
+ }
+
+ dest[di] = '\0';
+
+ return copied;
+}
+
+
size_t
rspamd_strlcpy_safe (gchar *dst, const gchar *src, gsize siz)
{
# define rspamd_strlcpy rspamd_strlcpy_fast
#endif
+/**
+ * Copies `srclen` characters from `src` to `dst` ignoring \0
+ * @param src
+ * @param srclen
+ * @param dest
+ * @param destlen
+ * @return number of bytes copied
+ */
+gsize
+rspamd_null_safe_copy (const gchar *src, gsize srclen,
+ gchar *dest, gsize destlen);
+
/*
* Try to convert string of length to long
*/