We shouldn't ask glibc to keep the old data around (which realloc() is
about), given we overwrite it entirely anyway. Let's hence speed things
up here, and allow glibc to just allocate a new block for us (and
shorten the code a bit)
}
/* We want +1 for the read call, and +3 for the additional terminating bytes added below. */
- char *t = realloc(buf, (size_t) st.st_size + MAX(1, 3));
- if (!t)
+ free(buf);
+ buf = malloc((size_t) st.st_size + MAX(1, 3));
+ if (!buf)
return -ENOMEM;
- buf = t;
const struct iovec iov[] = {
{ &attr, sizeof(attr) },