Linux file watcher: cleanup
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 18 Jul 2012 10:34:49 +0000 (12:34 +0200)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 18 Jul 2012 10:37:09 +0000 (12:37 +0200)
bin/linux/fsnotifier
bin/linux/fsnotifier64
native/fsNotifier/linux/main.c

index 6db5e802e80dfa914c23a16a255a1cfdee0aba1f..a69112111637b92ec5a42036a24dddbbc0e66bc4 100755 (executable)
Binary files a/bin/linux/fsnotifier and b/bin/linux/fsnotifier differ
index 71368b544bda515c921f2631dce9f1ca7662bc3d..355776567d548347b0af3af89bddcf780cfd3822 100755 (executable)
Binary files a/bin/linux/fsnotifier64 and b/bin/linux/fsnotifier64 differ
index 180140b344f7d28faa57eccb57f277320ebe914a..8a2ea11b551c4a29d16c1d0488decf5dc4946c28 100644 (file)
@@ -289,7 +289,7 @@ static bool update_roots(array* new_roots) {
 
   array_delete_vs_data(unwatchable);
   array_delete_vs_data(mounts);
-  array_delete(new_roots);
+  array_delete_vs_data(new_roots);
 
   return true;
 }
@@ -315,7 +315,6 @@ static bool register_roots(array* new_roots, array* unwatchable, array* mounts)
 
     if (unflattened[0] != '/') {
       userlog(LOG_WARNING, "  ... not valid, skipped");
-      free(new_root);
       continue;
     }
 
@@ -324,7 +323,8 @@ static bool register_roots(array* new_roots, array* unwatchable, array* mounts)
       char* mount = array_get(mounts, j);
       if (strncmp(mount, unflattened, strlen(mount)) == 0) {
         userlog(LOG_DEBUG, "path %s is under unwatchable %s - ignoring", unflattened, mount);
-        skip = unflattened;
+        skip = strdup(unflattened);
+        CHECK_NULL(skip, false);
         break;
       }
     }
@@ -340,26 +340,21 @@ static bool register_roots(array* new_roots, array* unwatchable, array* mounts)
       watch_root* root = malloc(sizeof(watch_root));
       CHECK_NULL(root, false);
       root->id = id;
-      root->name = new_root;
+      root->name = strdup(new_root);
+      CHECK_NULL(root->name, false);
       CHECK_NULL(array_push(roots, root), false);
     }
     else if (id == ERR_ABORT) {
       return false;
     }
-    else if (id == ERR_IGNORE) {
-      free(new_root);
-    }
-    else {
+    else if (id != ERR_IGNORE) {
       if (show_warning && watch_limit_reached()) {
         int limit = get_watch_count();
         userlog(LOG_WARNING, "watch limit (%d) reached", limit);
         output("MESSAGE\n" INOTIFY_LIMIT_MSG, limit);
         show_warning = false;  // warn only once
       }
-      char* copy = strdup(unflattened);
-      CHECK_NULL(copy, false);
-      CHECK_NULL(array_push(unwatchable, copy), false);
-      free(new_root);
+      CHECK_NULL(array_push(unwatchable, strdup(unflattened)), false);
     }
   }