2
0

probe.c 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Low-level libblkid probing API
  3. *
  4. * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
  5. *
  6. * This file may be redistributed under the terms of the
  7. * GNU Lesser General Public License.
  8. */
  9. #include <stdlib.h>
  10. #include "blkidP.h"
  11. #include "libblkid-tiny.h"
  12. static int blkid_probe_reset_buffers(struct blkid_struct_probe *pr);
  13. struct blkid_struct_probe *blkidtiny_new_probe(void)
  14. {
  15. struct blkid_struct_probe *pr;
  16. pr = calloc(1, sizeof(struct blkid_struct_probe));
  17. if (!pr)
  18. return NULL;
  19. INIT_LIST_HEAD(&pr->buffers);
  20. return pr;
  21. }
  22. void blkidtiny_free_probe(struct blkid_struct_probe *pr)
  23. {
  24. if (!pr)
  25. return;
  26. blkid_probe_reset_buffers(pr);
  27. free(pr);
  28. }
  29. static int blkid_probe_reset_buffers(struct blkid_struct_probe *pr)
  30. {
  31. if (list_empty(&pr->buffers))
  32. return 0;
  33. while (!list_empty(&pr->buffers)) {
  34. struct blkid_bufinfo *bf = list_first_entry(&pr->buffers, struct blkid_bufinfo, bufs);
  35. list_del(&bf->bufs);
  36. free(bf);
  37. }
  38. return 0;
  39. }