Change-Id: I1a6c75d8a2f64e58a4c81724e2c3b0568b581a7b
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
size_t alloc = 0;
while (1) {
- struct dirent entry;
struct dirent *result;
- if (readdir_r(d, &entry, &result) != 0) {
- fail:
- free(tasks);
- closedir(d);
- return -1;
- }
+ result = readdir(d);
if (result == NULL)
break;
if (result->d_type == DT_DIR && all_digits(result->d_name)) {
alloc = alloc > 0 ? (2 * alloc) : 8;
pid_t *ntasks = realloc(tasks,
sizeof(*tasks) * alloc);
- if (ntasks == NULL)
- goto fail;
+ if (ntasks == NULL) {
+ free(tasks);
+ closedir(d);
+ return -1;
+ }
tasks = ntasks;
}
assert(n < alloc);