aboutsummaryrefslogtreecommitdiff
path: root/cmd-string.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2014-10-21 12:35:58 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2014-10-21 12:35:58 +0100
commit201036ad80f2e51f7238db2adf05914a4a4f5819 (patch)
tree9ccaf6a087b551846b1c6e71a865cda3aac8c0f1 /cmd-string.c
parent65257b8e9b55d8d180265d714ba9b3637643c6dc (diff)
parent696b5a628f0f31f4c3566b5c0ab51fbd9f9f9880 (diff)
downloadrtmux-201036ad80f2e51f7238db2adf05914a4a4f5819.tar.gz
rtmux-201036ad80f2e51f7238db2adf05914a4a4f5819.tar.bz2
rtmux-201036ad80f2e51f7238db2adf05914a4a4f5819.zip
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'cmd-string.c')
-rw-r--r--cmd-string.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/cmd-string.c b/cmd-string.c
index e793ea02..fd483070 100644
--- a/cmd-string.c
+++ b/cmd-string.c
@@ -107,10 +107,11 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
case ' ':
case '\t':
if (buf != NULL) {
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len] = '\0';
- argv = xrealloc(argv, argc + 1, sizeof *argv);
+ argv = xreallocarray(argv, argc + 1,
+ sizeof *argv);
argv[argc++] = buf;
buf = NULL;
@@ -151,7 +152,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file,
if (len >= SIZE_MAX - 2)
goto error;
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len++] = ch;
break;
}
@@ -179,7 +180,7 @@ cmd_string_copy(char **dst, char *src, size_t *len)
srclen = strlen(src);
- *dst = xrealloc(*dst, 1, *len + srclen + 1);
+ *dst = xrealloc(*dst, *len + srclen + 1);
strlcpy(*dst + *len, src, srclen + 1);
*len += srclen;
@@ -231,11 +232,11 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
if (len >= SIZE_MAX - 2)
goto error;
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len++] = ch;
}
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len] = '\0';
return (buf);
@@ -278,7 +279,7 @@ cmd_string_variable(const char *s, size_t *p)
return (t);
}
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len++] = ch;
for (;;) {
@@ -288,7 +289,7 @@ cmd_string_variable(const char *s, size_t *p)
else {
if (len >= SIZE_MAX - 3)
goto error;
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len++] = ch;
}
}
@@ -299,7 +300,7 @@ cmd_string_variable(const char *s, size_t *p)
if (ch != EOF && fch != '{')
cmd_string_ungetc(p); /* ch */
- buf = xrealloc(buf, 1, len + 1);
+ buf = xrealloc(buf, len + 1);
buf[len] = '\0';
envent = environ_find(&global_environ, buf);