]> Pileus Git - wmpus/blobdiff - util.c
Try to improve focus speed
[wmpus] / util.c
diff --git a/util.c b/util.c
index cb196bffb6e6bb78674e78f76f03aa5b72d023df..cfe69a9b863e1d1a1b80825c506209b7dffc3f6c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -55,12 +55,14 @@ list_t *list_append(list_t *head, void *data)
        return last ? head : node;
 }
 
-list_t *list_remove(list_t *head, list_t *node)
+list_t *list_remove(list_t *head, list_t *node, int freedata)
 {
        list_t *next = node->next;
        list_t *prev = node->prev;
        if (next) next->prev = prev;
        if (prev) prev->next = next;
+       if (freedata)
+               free(node->data);
        free(node);
        return head == node ? next : head;
 }
@@ -89,6 +91,13 @@ list_t *list_find(list_t *list, void *data)
 }
 
 /* Misc */
+int str2num(char *str, int def)
+{
+       char *end = NULL;
+       int num = strtol(str, &end, 10);
+       return end && *end == '\0' ? num : def;
+}
+
 int error(char *fmt, ...)
 {
        va_list ap;