mirror of
https://github.com/swaywm/sway.git
synced 2026-04-29 06:46:22 -04:00
fixes
This commit is contained in:
parent
6460a15d94
commit
f5d346d304
7 changed files with 16 additions and 21 deletions
|
|
@ -83,10 +83,6 @@ list_t *split_string(const char *str, const char *delims) {
|
|||
return res;
|
||||
}
|
||||
|
||||
void free_flat_list(list_t *list) {
|
||||
list_free_withp(list, free);
|
||||
}
|
||||
|
||||
char **split_args(const char *start, int *argc) {
|
||||
*argc = 0;
|
||||
int alloc = 2;
|
||||
|
|
@ -312,18 +308,18 @@ char *join_list(list_t *list, char *separator) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < list->length; i++) {
|
||||
char *item = *(char **)list_get(list, i);
|
||||
char *item = list_getp(list, i);
|
||||
len += strlen(item);
|
||||
}
|
||||
|
||||
char *res = malloc(len);
|
||||
|
||||
char *item = *(char **)list_get(list, 0);
|
||||
char *item = list_getp(list, 0);
|
||||
char *p = res + strlen(item);
|
||||
strcpy(res, item);
|
||||
|
||||
for (size_t i = 1; i < list->length; i++) {
|
||||
item = *(char **)list_get(list, i);
|
||||
item = list_getp(list, i);
|
||||
if (sep_len) {
|
||||
memcpy(p, separator, sep_len);
|
||||
p += sep_len;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@ int strcmp_ptr(const void *a, const void *b);
|
|||
// strcmp that also handles null pointers.
|
||||
int lenient_strcmp(char *a, char *b);
|
||||
|
||||
// Simply split a string with delims, free with `free_flat_list`
|
||||
// Simply split a string with delims, free with `list_free_withp(..., free)`
|
||||
list_t *split_string(const char *str, const char *delims);
|
||||
void free_flat_list(list_t *list);
|
||||
|
||||
// Splits an argument string, keeping quotes intact
|
||||
char **split_args(const char *str, int *argc);
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
|
|||
mod |= tmp_mod;
|
||||
continue;
|
||||
} else {
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
return cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", item);
|
||||
}
|
||||
}
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
|
||||
config->current_bar->modifier = mod;
|
||||
sway_log(L_DEBUG, "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
|
||||
|
|
|
|||
|
|
@ -63,21 +63,21 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
|||
}
|
||||
if (!sym) {
|
||||
free_sway_binding(binding);
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
return cmd_results_new(CMD_INVALID, "bindsym", "Unknown key '%s'",
|
||||
item);
|
||||
}
|
||||
xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t));
|
||||
if (!key) {
|
||||
free_sway_binding(binding);
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
return cmd_results_new(CMD_FAILURE, "bindsym",
|
||||
"Unable to allocate binding");
|
||||
}
|
||||
*key = sym;
|
||||
list_add(binding->keys, &key);
|
||||
}
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
|
||||
struct sway_mode *mode = config->current_mode;
|
||||
struct sway_binding *dup;
|
||||
|
|
@ -148,7 +148,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
|||
*key = keycode - 8;
|
||||
list_add(binding->keys, &key);
|
||||
}
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
|
||||
struct sway_mode *mode = config->current_mode;
|
||||
struct sway_binding *dup;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct cmd_results *cmd_floating_mod(int argc, char **argv) {
|
|||
for (size_t i = 0; i < split->length; ++i) {
|
||||
config->floating_mod |= get_modifier_mask_by_name(list_getp(split, i));
|
||||
}
|
||||
free_flat_list(split);
|
||||
list_free_withp(split, free);
|
||||
if (!config->floating_mod) {
|
||||
error = cmd_results_new(CMD_INVALID, "floating_modifier", "Unknown keys %s", argv[0]);
|
||||
return error;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static void free_binding(struct sway_binding *bind) {
|
|||
if (!bind) {
|
||||
return;
|
||||
}
|
||||
free_flat_list(bind->keys);
|
||||
list_free_withp(bind->keys, free);
|
||||
free(bind->command);
|
||||
free(bind);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ static void free_bar(struct bar_config *bar) {
|
|||
list_free(bar->bindings);
|
||||
|
||||
if (bar->outputs) {
|
||||
free_flat_list(bar->outputs);
|
||||
list_free_withp(bar->outputs, free);
|
||||
}
|
||||
|
||||
if (bar->pid != 0) {
|
||||
|
|
@ -229,7 +229,7 @@ void free_config(struct sway_config *config) {
|
|||
list_free_withp(config->feature_policies, (freefn_t)free_feature_policy);
|
||||
|
||||
list_free(config->active_bar_modifiers);
|
||||
free_flat_list(config->config_chain);
|
||||
list_free_withp(config->config_chain, free);
|
||||
free(config->font);
|
||||
free(config->floating_scroll_up_cmd);
|
||||
free(config->floating_scroll_down_cmd);
|
||||
|
|
@ -514,7 +514,7 @@ bool load_main_config(const char *file, bool is_active) {
|
|||
}
|
||||
}
|
||||
|
||||
free_flat_list(secconfigs);
|
||||
list_free_withp(secconfigs, free);
|
||||
}
|
||||
|
||||
success = success && load_config(path, config);
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ void registry_teardown(struct registry *registry) {
|
|||
wl_display_disconnect(registry->display);
|
||||
}
|
||||
if (registry->outputs) {
|
||||
free_flat_list(registry->outputs);
|
||||
list_free_withp(registry->outputs, free);
|
||||
}
|
||||
free(registry);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue