-
-void *tal_grab_file(const void *ctx, const char *filename, size_t *size)
-{
- struct rbuf rbuf;
- char *buf = tal_arr(ctx, char, 0);
-
- if (!rbuf_open(&rbuf, filename, buf, 0))
- return tal_free(buf);
-
- if (!rbuf_fill_all(&rbuf, do_tal_realloc) && errno)
- rbuf.buf = tal_free(rbuf.buf);
- else {
- rbuf.buf[rbuf.len] = '\0';
- if (size)
- *size = rbuf.len;
- }
- close(rbuf.fd);
-
- return rbuf.buf;
-}