diff options
author | nicm <nicm> | 2015-04-25 18:47:01 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-04-25 18:47:01 +0000 |
commit | a568b9cadce002f6f7e8ee914c995242bd70cce5 (patch) | |
tree | 6af80f111e386519c3f878fb8f4bab7569b74e4e /cfg.c | |
parent | 07dfdb974d36f1eee084b9739d2b8a5b64172ec8 (diff) |
Use a char **,u_int pair for cfg_causes.
Diffstat (limited to 'cfg.c')
-rw-r--r-- | cfg.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -30,7 +30,8 @@ struct cmd_q *cfg_cmd_q; int cfg_finished; int cfg_references; -ARRAY_DECL (, char *) cfg_causes = ARRAY_INITIALIZER; +char** cfg_causes; +u_int cfg_ncauses; struct client *cfg_client; int @@ -122,40 +123,42 @@ cfg_add_cause(const char* fmt, ...) xvasprintf(&msg, fmt, ap); va_end (ap); - ARRAY_ADD(&cfg_causes, msg); + cfg_ncauses++; + cfg_causes = xreallocarray(cfg_causes, cfg_ncauses, sizeof *cfg_causes); + cfg_causes[cfg_ncauses - 1] = msg; } void cfg_print_causes(struct cmd_q *cmdq) { - char *cause; u_int i; - for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { - cause = ARRAY_ITEM(&cfg_causes, i); - cmdq_print(cmdq, "%s", cause); - free(cause); + for (i = 0; i < cfg_ncauses; i++) { + cmdq_print(cmdq, "%s", cfg_causes[i]); + free(cfg_causes[i]); } - ARRAY_FREE(&cfg_causes); + + free(cfg_causes); + cfg_causes = NULL; } void cfg_show_causes(struct session *s) { struct window_pane *wp; - char *cause; u_int i; - if (s == NULL || ARRAY_EMPTY(&cfg_causes)) + if (s == NULL || cfg_ncauses == 0) return; wp = s->curw->window->active; window_pane_set_mode(wp, &window_copy_mode); window_copy_init_for_output(wp); - for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { - cause = ARRAY_ITEM(&cfg_causes, i); - window_copy_add(wp, "%s", cause); - free(cause); + for (i = 0; i < cfg_ncauses; i++) { + window_copy_add(wp, "%s", cfg_causes[i]); + free(cfg_causes[i]); } - ARRAY_FREE(&cfg_causes); + + free(cfg_causes); + cfg_causes = NULL; } |