mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 00:11:28 +00:00
Add remaining sway allocation failure handling
This commit is contained in:
parent
7784f1a905
commit
a2b9149656
|
@ -217,7 +217,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
|
||||||
workspace->y = output->y;
|
workspace->y = output->y;
|
||||||
workspace->width = output->width;
|
workspace->width = output->width;
|
||||||
workspace->height = output->height;
|
workspace->height = output->height;
|
||||||
workspace->name = strdup(name);
|
workspace->name = !name ? NULL : strdup(name);
|
||||||
workspace->visible = false;
|
workspace->visible = false;
|
||||||
workspace->floating = create_list();
|
workspace->floating = create_list();
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,10 @@ char *workspace_next_name(const char *output_name) {
|
||||||
l = 3;
|
l = 3;
|
||||||
}
|
}
|
||||||
char *name = malloc(l + 1);
|
char *name = malloc(l + 1);
|
||||||
|
if (!name) {
|
||||||
|
sway_log(L_ERROR, "Could not allocate workspace name");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
sprintf(name, "%d", ws_num++);
|
sprintf(name, "%d", ws_num++);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -279,6 +283,10 @@ bool workspace_switch(swayc_t *workspace) {
|
||||||
&& active_ws != workspace)) {
|
&& active_ws != workspace)) {
|
||||||
free(prev_workspace_name);
|
free(prev_workspace_name);
|
||||||
prev_workspace_name = malloc(strlen(active_ws->name) + 1);
|
prev_workspace_name = malloc(strlen(active_ws->name) + 1);
|
||||||
|
if (!prev_workspace_name) {
|
||||||
|
sway_log(L_ERROR, "Unable to allocate previous workspace name");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
strcpy(prev_workspace_name, active_ws->name);
|
strcpy(prev_workspace_name, active_ws->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue