common/string-helpers.c: add strdup_printf()

This commit is contained in:
Johan Malm 2023-06-25 09:00:41 +01:00 committed by Johan Malm
parent 41de529fff
commit f4f35a9dff
4 changed files with 47 additions and 23 deletions

View file

@ -1096,11 +1096,9 @@ post_processing(void)
int nr_workspaces = wl_list_length(&rc.workspace_config.workspaces);
if (nr_workspaces < rc.workspace_config.min_nr_workspaces) {
struct workspace *workspace;
char workspace_name[32];
for (int i = nr_workspaces; i < rc.workspace_config.min_nr_workspaces; i++) {
workspace = znew(*workspace);
snprintf(workspace_name, sizeof(workspace_name), "Workspace %d", i + 1);
workspace->name = xstrdup(workspace_name);
workspace->name = strdup_printf("Workspace %d", i + 1);
wl_list_append(&rc.workspace_config.workspaces, &workspace->link);
}
}