This doesn't make the code pretty, but it at least makes it a tiny bit shorter.
static int checkout(int fd)
{
int len;
- char *buf, *ptr, *word = NULL;
+ _cleanup_free_ char *buf = NULL;
+ char *ptr, *word = NULL;
struct _mate *him;
restart:
bufsize = bufsize << 1;
if (debug)
fprintf(stderr, "ID overflow, restarting with size %zu\n", bufsize);
- free(buf);
lseek(fd, 0, SEEK_SET);
goto restart;
}
if (debug)
fprintf(stderr, "Found word %s\n", word);
him = malloc(sizeof (struct _mate));
- if (!him) {
- free(buf);
+ if (!him)
return log_oom();
- }
him->name = strdup(word);
if (!him->name) {
- free(buf);
free(him);
return log_oom();
}
ptr -= len;
}
- free(buf);
return 0;
}