diff options
author | taiyu <[email protected]> | 2015-09-07 15:03:04 -0700 |
---|---|---|
committer | taiyu <[email protected]> | 2015-09-07 15:03:04 -0700 |
commit | 3eb29ea7364724af99e4f4a5f7a6f633e17baf8d (patch) | |
tree | 8496fd8673d31bac1802d756885a8fc64245a552 /sway/commands.c | |
parent | 47ff0006975a2fcab2178b729deec675c2283363 (diff) |
strdup + style
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sway/commands.c b/sway/commands.c index 72d53ff0..e7ddfa71 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -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; } |