ifndef CONFIG_STRLCAT
SOURCE += oslib/strlcat.c
endif
+ifndef CONFIG_HAVE_STRNDUP
+ SOURCE += oslib/strndup.c
+endif
ifndef CONFIG_GETOPT_LONG_ONLY
SOURCE += oslib/getopt_long.c
endif
fi
print_config "bool" "$have_bool"
+##########################################
+# Check whether we have strndup()
+cat > $TMPC << EOF
+#include <string.h>
+#include <stdlib.h>
+int main(int argc, char **argv)
+{
+ char *res = strndup("test string", 8);
+
+ free(res);
+ return 0;
+}
+EOF
+if compile_prog "" "" "strndup"; then
+ strndup="yes"
+fi
+print_config "strndup" "$strndup"
+
##########################################
# check march=armv8-a+crc+crypto
if test "$march_armv8_a_crc_crypto" != "yes" ; then
if test "$have_bool" = "yes" ; then
output_sym "CONFIG_HAVE_BOOL"
fi
+if test "$strndup" = "yes" ; then
+ output_sym "CONFIG_HAVE_STRNDUP"
+fi
if test "$disable_opt" = "yes" ; then
output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
fi
#include "pattern.h"
#include "../minmax.h"
#include "../oslib/strcasestr.h"
+#include "../oslib/strndup.h"
/**
* parse_file() - parses binary file to fill buffer
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef CONFIG_HAVE_STRNDUP
+
+char *strndup(const char *s, size_t n)
+{
+ char *str = malloc(n + 1);
+
+ if (str) {
+ strncpy(str, s, n);
+ str[n] = '\0';
+ }
+
+ return str;
+}
+
+#endif