+ free(dev);
+ dev = NULL;
+}
+
+
+/*
+ * free all the nodes after the "dev" and includes itself
+ */
+static void log_devices_chain_free(struct log_device_t *dev)
+{
+ if (!dev)
+ return;
+
+ while (dev->next) {
+ struct log_device_t *tmp = dev->next;
+ dev->next = tmp->next;
+ log_devices_free(tmp);
+ }
+
+ log_devices_free(dev);
+ dev = NULL;
+}
+
+
+/*
+ * create a new log_device_t instance but don't care about
+ * the device node accessable or not
+ */
+static struct log_device_t *log_devices_new(const char *path)
+{
+ struct log_device_t *new;
+
+ if (!path || strlen(path) <= 0)
+ return NULL;
+
+ new = malloc(sizeof(*new));
+ if (!new) {
+ fprintf(stderr, "out of memory\n");
+ return NULL;
+ }