libfstools: use container_of for volume private data
[project/fstools.git] / libfstools / volume.c
index 8f920e0d06c1b172166ea043144abc60221e9a35..0d293d54ea738acc9f308eaddcfe297ca94b3d7f 100644 (file)
@@ -28,20 +28,16 @@ volume_register_driver(struct driver *d)
 
 struct volume* volume_find(char *name)
 {
 
 struct volume* volume_find(char *name)
 {
-       struct volume *v = malloc(sizeof(struct volume));
+       struct volume *v;
        struct driver *d;
 
        struct driver *d;
 
-       if (!v)
-               return NULL;
-
        list_for_each_entry(d, &drivers, list) {
        list_for_each_entry(d, &drivers, list) {
-               memset(v, 0, sizeof(struct volume));
-
-               if (d->find && !d->find(v, name))
-                       return v;
+               if (d->find) {
+                       v = d->find(name);
+                       if (v)
+                               return v;
+               }
        }
 
        }
 
-       free(v);
-
        return NULL;
 }
        return NULL;
 }