]> git.sur5r.net Git - i3/i3/blobdiff - src/util.c
Reduce some code around frees
[i3/i3] / src / util.c
index ba0969c729674aabe3dd04a0ce9614803514f4f7..594d2bb6d038b0c943681197cd2a8aaf7a5f2a09 100644 (file)
@@ -500,10 +500,17 @@ ssize_t slurp(const char *path, char **buf) {
     size_t n = fread(*buf, 1, stbuf.st_size, f);
     fclose(f);
     if ((ssize_t)n != stbuf.st_size) {
-        ELOG("File \"%s\" could not be read entirely: got %zd, want %zd\n", path, n, stbuf.st_size);
-        free(*buf);
-        *buf = NULL;
+        ELOG("File \"%s\" could not be read entirely: got %zd, want %" PRIi64 "\n", path, n, (int64_t)stbuf.st_size);
+        FREE(*buf);
         return -1;
     }
     return (ssize_t)n;
 }
+
+/*
+ * Convert a direction to its corresponding orientation.
+ *
+ */
+orientation_t orientation_from_direction(direction_t direction) {
+    return (direction == D_LEFT || direction == D_RIGHT) ? HORIZ : VERT;
+}