strdup + style

This commit is contained in:
taiyu 2015-09-07 15:03:04 -07:00
parent 47ff000697
commit 3eb29ea736
3 changed files with 7 additions and 13 deletions

View file

@ -383,9 +383,8 @@ static bool cmd_mode(int argc, char **argv) {
// Create mode if it doesnt exist
if (!mode && argc >= 2 && strncmp(argv[1],"{",1) == 0) {
mode = malloc(sizeof*mode);
mode->name = malloc(strlen(mode_name) + 1);
mode->name = strdup(mode_name);
mode->bindings = create_list();
strcpy(mode->name, mode_name);
list_add(config->modes, mode);
}
if (!mode) {
@ -834,10 +833,8 @@ static bool cmd_set(int argc, char **argv) {
return false;
}
struct sway_variable *var = malloc(sizeof(struct sway_variable));
var->name = malloc(strlen(argv[0]) + 1);
strcpy(var->name, argv[0]);
var->value = malloc(strlen(argv[1]) + 1);
strcpy(var->value, argv[1]);
var->name = strdup(argv[0]);
var->value = strdup(argv[1]);
list_add(config->symbols, var);
return true;
}