summaryrefslogtreecommitdiffstats
path: root/sway/commands/bar.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2019-01-22 10:43:48 +0000
committerLibravatar emersion <contact@emersion.fr>2019-01-22 13:10:25 +0100
commitde9a357de84da4436b263ff6a969eb4ac753af0d (patch)
tree6a2f05fe18a6152335c832a20e1f7c543badcf48 /sway/commands/bar.c
parentRemove assumption that noop output will be called NOOP-1 (diff)
downloadsway-de9a357de84da4436b263ff6a969eb4ac753af0d.tar.gz
sway-de9a357de84da4436b263ff6a969eb4ac753af0d.tar.zst
sway-de9a357de84da4436b263ff6a969eb4ac753af0d.zip
util.c: remove numlen function
Its uses have been replaced by snprintf, which is more in line with its usage.
Diffstat (limited to 'sway/commands/bar.c')
-rw-r--r--sway/commands/bar.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index e9360603..82441f9e 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -1,10 +1,10 @@
1#define _POSIX_C_SOURCE 200809 1#define _POSIX_C_SOURCE 200809
2#include <stdio.h>
2#include <string.h> 3#include <string.h>
3#include <strings.h> 4#include <strings.h>
4#include "sway/commands.h" 5#include "sway/commands.h"
5#include "sway/config.h" 6#include "sway/config.h"
6#include "log.h" 7#include "log.h"
7#include "util.h"
8 8
9// Must be in alphabetical order for bsearch 9// Must be in alphabetical order for bsearch
10static struct cmd_handler bar_handlers[] = { 10static struct cmd_handler bar_handlers[] = {
@@ -89,7 +89,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
89 } 89 }
90 90
91 // set bar id 91 // set bar id
92 const int len = 5 + numlen(config->bars->length - 1); // "bar-"+i+\0 92 const int len = snprintf(NULL, 0, "bar-%d", config->bars->length - 1) + 1;
93 bar->id = malloc(len * sizeof(char)); 93 bar->id = malloc(len * sizeof(char));
94 if (bar->id) { 94 if (bar->id) {
95 snprintf(bar->id, len, "bar-%d", config->bars->length - 1); 95 snprintf(bar->id, len, "bar-%d", config->bars->length - 1);