From 3cf19d6dd0900dd5bbd78594af308ee88b109756 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 17 Nov 2016 10:06:08 +0000 Subject: Key running commands for #() by the unexpanded command, and run them again if the expanded form changes (otherwise at most once per second as usual). Fixes issues reported by Gregory Pakosz. --- xmalloc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'xmalloc.c') diff --git a/xmalloc.c b/xmalloc.c index fcb8481d..22ea3540 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -81,6 +81,16 @@ xstrdup(const char *str) return cp; } +char * +xstrndup(const char *str, size_t maxlen) +{ + char *cp; + + if ((cp = strndup(str, maxlen)) == NULL) + fatalx("xstrndup: %s", strerror(errno)); + return cp; +} + int xasprintf(char **ret, const char *fmt, ...) { -- cgit