summaryrefslogtreecommitdiff
path: root/i3status.c
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2014-12-07 23:32:19 +0300
committerMichael Stapelberg <michael@stapelberg.de>2014-12-10 19:58:54 +0100
commit3818dabcebea7f98e3dfdfbe5be42374bb60cf88 (patch)
treeb0c7d2ad25f8c8095e0c7104ca883f9120bc3fbd /i3status.c
parentb219f47f394e536198997578e4cce3c539b84b6d (diff)
Allocate and expose per-instance pointers for plugins
Diffstat (limited to 'i3status.c')
-rw-r--r--i3status.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/i3status.c b/i3status.c
index daa2d00..7c98d06 100644
--- a/i3status.c
+++ b/i3status.c
@@ -56,6 +56,8 @@ static bool exit_upon_signal = false;
cfg_t *cfg, *cfg_general, *cfg_section;
+void **cur_instance;
+
/*
* Set the exit_upon_signal flag, because one cannot do anything in a safe
* manner in a signal handler (e.g. fprintf, which we really want to do for
@@ -550,6 +552,8 @@ int main(int argc, char *argv[]) {
* (!), not individual plugins, seem very unlikely. */
char buffer[4096];
+ void **per_instance = calloc(cfg_size(cfg, "order"), sizeof(*per_instance));
+
while (1) {
if (exit_upon_signal) {
fprintf(stderr, "Exiting due to signal.\n");
@@ -563,6 +567,7 @@ int main(int argc, char *argv[]) {
/* Restore the cursor-position, clear line */
printf("\033[u\033[K");
for (j = 0; j < cfg_size(cfg, "order"); j++) {
+ cur_instance = per_instance + j;
if (j > 0)
print_separator(separator);