]> git.sur5r.net Git - i3/i3/blobdiff - i3-input/main.c
i3-input: fix (irrelevant) memory leak
[i3/i3] / i3-input / main.c
index 49db4df231dd234260e30369d3f589353140b78f..c9ebd0103bf58d337cbf146fe99467c2d20b0c30 100644 (file)
@@ -57,7 +57,7 @@ xcb_screen_t *root_screen;
 static xcb_get_input_focus_cookie_t focus_cookie;
 
 /*
- * Having verboselog() and errorlog() is necessary when using libi3.
+ * Having verboselog(), errorlog() and debuglog() is necessary when using libi3.
  *
  */
 void verboselog(char *fmt, ...) {
@@ -76,6 +76,9 @@ void errorlog(char *fmt, ...) {
     va_end(args);
 }
 
+void debuglog(char *fmt, ...) {
+}
+
 /*
  * Restores the X11 input focus to whereever it was before.
  * This is necessary because i3-input’s window has override_redirect=1
@@ -211,6 +214,8 @@ static void finish_input() {
 
     ipc_send_message(sockfd, strlen(full), 0, (uint8_t*)full);
 
+    free(full);
+
 #if 0
     free(command);
     return 1;
@@ -368,23 +373,23 @@ int main(int argc, char *argv[]) {
 
     printf("using format \"%s\"\n", format);
 
+    int screen;
+    conn = xcb_connect(NULL, &screen);
+    if (!conn || xcb_connection_has_error(conn))
+        die("Cannot open display\n");
+
     if (socket_path == NULL)
-        socket_path = root_atom_contents("I3_SOCKET_PATH");
+        socket_path = root_atom_contents("I3_SOCKET_PATH", conn, screen);
 
     if (socket_path == NULL)
         socket_path = "/tmp/i3-ipc.sock";
 
     sockfd = ipc_connect(socket_path);
 
-    int screens;
-    conn = xcb_connect(NULL, &screens);
-    if (!conn || xcb_connection_has_error(conn))
-        die("Cannot open display\n");
-
     /* Request the current InputFocus to restore when i3-input exits. */
     focus_cookie = xcb_get_input_focus(conn);
 
-    root_screen = xcb_aux_get_screen(conn, screens);
+    root_screen = xcb_aux_get_screen(conn, screen);
     root = root_screen->root;
 
     symbols = xcb_key_symbols_alloc(conn);