From d0c0f5247bd11a788b4f173ca6241b51a3adb458 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl <0x6A73@pm.me> Date: Thu, 25 Apr 2024 00:22:01 -0600 Subject: tidy some code + scroll patch --- st.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'st.c') diff --git a/st.c b/st.c index 9c7ff35..d15846c 100644 --- a/st.c +++ b/st.c @@ -1,4 +1,5 @@ -/* See LICENSE for license details. */ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X #include #include #include @@ -256,11 +257,13 @@ void *xrealloc(void *p, size_t len) { return p; } -char *xstrdup(char *s) { - if ((s = strdup(s)) == NULL) +char *xstrdup(const char *s) { + char *p; + + if ((p = strdup(s)) == NULL) die("strdup: %s\n", strerror(errno)); - return s; + return p; } size_t utf8decode(const char *c, Rune *u, size_t clen) { @@ -687,7 +690,7 @@ void stty(char **args) { perror("Couldn't call stty"); } -int ttynew(char *line, char *cmd, char *out, char **args) { +int ttynew(const char *line, char *cmd, const char *out, char **args) { int m, s; if (out) { -- cgit v1.2.3