From ed3fcd63fc7fb1c4061fbabc5fbd66eb2f3c2ed3 Mon Sep 17 00:00:00 2001 From: o9000 Date: Wed, 18 May 2016 23:27:55 +0200 Subject: [PATCH] Tint2conf: use strcat instead of append (issue #580) --- src/tint2conf/properties_rw.c | 11 ++++++----- src/util/common.c | 11 ----------- src/util/common.h | 3 --- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index e4b6380..f9070d0 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -158,15 +158,16 @@ void config_write_backgrounds(FILE *fp) fprintf(fp, "rounded = %d\n", r); fprintf(fp, "border_width = %d\n", b); - char *sides = "\0"; + char sides[10]; + sides[0] = '\0'; if (sideTop) - sides = append(sides, 'T'); + strcat(sides, "T"); if (sideBottom) - sides = append(sides, 'B'); + strcat(sides, "B"); if (sideLeft) - sides = append(sides, 'L'); + strcat(sides, "L"); if (sideRight) - sides = append(sides, 'R'); + strcat(sides, "R"); fprintf(fp, "border_sides = %s\n", sides); config_write_color(fp, "background_color", *fillColor, fillOpacity); diff --git a/src/util/common.c b/src/util/common.c index 09e01eb..4a50e03 100644 --- a/src/util/common.c +++ b/src/util/common.c @@ -44,17 +44,6 @@ #include #endif -char *append(char *s, char c) { - int len = strlen(s); - char buf[len+2]; - - strcpy(buf, s); - buf[len] = c; - buf[len + 1] = 0; - - return strdup(buf); -} - void copy_file(const char *path_src, const char *path_dest) { if (g_str_equal(path_src, path_dest)) diff --git a/src/util/common.h b/src/util/common.h index bbb4e02..c2a907f 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -41,9 +41,6 @@ typedef enum MouseAction { #define ALL_DESKTOPS 0xFFFFFFFF -// add c to s -char *append(char *s, char c); - // Copies a file to another path void copy_file(const char *path_src, const char *path_dest);