diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,9 +1,10 @@ #include "common.h" static int cmp_block_device(const void *aa, const void *bb) { - const char *a = ((struct Block_Device *) aa)->path; - const char *b = ((struct Block_Device *) bb)->path; - return strcmp(a, b) == 0; + struct Block_Device *a = *(struct Block_Device **) aa; + struct Block_Device *b = *(struct Block_Device **) bb; + + return strcmp(a->path, b->path); } int main() { @@ -53,7 +54,7 @@ int main() { if (!block_device) { fprintf(stderr, "Unable to enumerate block devices\n"); } else { - qsort(block_device, device_count, sizeof(block_device), cmp_block_device); + qsort(block_device, device_count, sizeof(block_device[0]), cmp_block_device); for (size_t bd = 0; bd < device_count; bd++) { struct Block_Device *p; p = block_device[bd]; @@ -61,5 +62,14 @@ int main() { } } + for (size_t i = 0; i < device_count; i++) { + free(block_device[i]->path); + free(block_device[i]->model); + free(block_device[i]); + } + free(block_device); + free(distro_name); + free(distro_version); + return 0; } |