Merge branch 'master' into next

This commit is contained in:
Michael Stapelberg 2011-08-09 09:27:55 +02:00
commit 4253aa4ba2
6 changed files with 12 additions and 4 deletions

View File

@ -39,7 +39,9 @@ void run_assignments(i3Window *window) {
DLOG("execute command %s\n", current->dest.command); DLOG("execute command %s\n", current->dest.command);
char *full_command; char *full_command;
asprintf(&full_command, "[id=\"%d\"] %s", window->id, current->dest.command); asprintf(&full_command, "[id=\"%d\"] %s", window->id, current->dest.command);
parse_cmd(full_command); char *json_result = parse_cmd(full_command);
FREE(full_command);
FREE(json_result);
} }
/* Store that we ran this assignment to not execute it again */ /* Store that we ran this assignment to not execute it again */

View File

@ -1150,6 +1150,7 @@ colorpixel:
char *hex; char *hex;
if (asprintf(&hex, "#%s", $2) == -1) if (asprintf(&hex, "#%s", $2) == -1)
die("asprintf()"); die("asprintf()");
free($2);
$$ = get_colorpixel(hex); $$ = get_colorpixel(hex);
free(hex); free(hex);
} }

View File

@ -81,13 +81,13 @@ int cmdyywrap() {
} }
char *parse_cmd(const char *new) { char *parse_cmd(const char *new) {
json_output = NULL;
LOG("COMMAND: *%s*\n", new); LOG("COMMAND: *%s*\n", new);
cmdyy_scan_string(new); cmdyy_scan_string(new);
match_init(&current_match); match_init(&current_match);
context = scalloc(sizeof(struct context)); context = scalloc(sizeof(struct context));
context->filename = "cmd"; context->filename = "cmd";
FREE(json_output);
if (cmdyyparse() != 0) { if (cmdyyparse() != 0) {
fprintf(stderr, "Could not parse command\n"); fprintf(stderr, "Could not parse command\n");
asprintf(&json_output, "{\"success\":false, \"error\":\"%s at position %d\"}", asprintf(&json_output, "{\"success\":false, \"error\":\"%s at position %d\"}",

View File

@ -193,6 +193,7 @@ static char *get_config_path(const char *override_configpath) {
config_path = resolve_tilde("~/.i3/config"); config_path = resolve_tilde("~/.i3/config");
if (path_exists(config_path)) if (path_exists(config_path))
return config_path; return config_path;
free(config_path);
/* 2: check for $XDG_CONFIG_HOME/i3/config */ /* 2: check for $XDG_CONFIG_HOME/i3/config */
if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL) if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL)

View File

@ -112,7 +112,8 @@ static int handle_key_press(xcb_key_press_event_t *event) {
} }
} }
parse_cmd(bind->command); char *json_result = parse_cmd(bind->command);
FREE(json_result);
return 1; return 1;
} }

View File

@ -147,7 +147,8 @@ IPC_HANDLER(command) {
char *command = scalloc(message_size + 1); char *command = scalloc(message_size + 1);
strncpy(command, (const char*)message, message_size); strncpy(command, (const char*)message, message_size);
LOG("IPC: received: *%s*\n", command); LOG("IPC: received: *%s*\n", command);
const char *reply = parse_cmd((const char*)command); char *reply = parse_cmd((const char*)command);
char *save_reply = reply;
free(command); free(command);
/* If no reply was provided, we just use the default success message */ /* If no reply was provided, we just use the default success message */
@ -155,6 +156,8 @@ IPC_HANDLER(command) {
reply = "{\"success\":true}"; reply = "{\"success\":true}";
ipc_send_message(fd, (const unsigned char*)reply, ipc_send_message(fd, (const unsigned char*)reply,
I3_IPC_REPLY_TYPE_COMMAND, strlen(reply)); I3_IPC_REPLY_TYPE_COMMAND, strlen(reply));
FREE(save_reply);
} }
static void dump_rect(yajl_gen gen, const char *name, Rect r) { static void dump_rect(yajl_gen gen, const char *name, Rect r) {