summaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authornicm <nicm>2016-11-17 10:06:08 +0000
committernicm <nicm>2016-11-17 10:06:08 +0000
commit3cf19d6dd0900dd5bbd78594af308ee88b109756 (patch)
treebd0bf36fc064cd633f9edb3a5630b047806fa74b /xmalloc.c
parentddf7ac5ae4d044cda12d959bbf02df921f9d84a5 (diff)
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.
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c10
1 files changed, 10 insertions, 0 deletions
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, ...)
{