diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-09 16:09:16 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-09 16:45:28 -0400 |
commit | 7432b24b8357d913943580b442ffe7040e610f9e (patch) | |
tree | e7d1afef78e25cbefdbbbafd92dc0d3bf14df3aa /src/shared | |
parent | 0797f2329ceeb989147416bdb368de4c21bad608 (diff) |
efivars: use greedy_realloc
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/efivars.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/shared/efivars.c b/src/shared/efivars.c index 8b2b6af4bc..d3bec5092d 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -504,6 +504,7 @@ int efi_get_boot_options(uint16_t **options) { _cleanup_closedir_ DIR *dir = NULL; struct dirent *de; _cleanup_free_ uint16_t *list = NULL; + size_t alloc = 0; int count = 0; assert(options); @@ -514,7 +515,6 @@ int efi_get_boot_options(uint16_t **options) { FOREACH_DIRENT(de, dir, return -errno) { int id; - uint16_t *t; if (strncmp(de->d_name, "Boot", 4) != 0) continue; @@ -529,12 +529,10 @@ int efi_get_boot_options(uint16_t **options) { if (id < 0) continue; - t = realloc(list, (count + 1) * sizeof(uint16_t)); - if (!t) + if (!GREEDY_REALLOC(list, alloc, count + 1)) return -ENOMEM; - list = t; - list[count ++] = id; + list[count++] = id; } qsort_safe(list, count, sizeof(uint16_t), cmp_uint16); |