diff options
author | Colin Walters <walters@verbum.org> | 2017-10-08 15:55:35 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-10-11 19:04:46 +0000 |
commit | bb51a43d8111416bdd8225487ba803c34ad5b69b (patch) | |
tree | a9e6a42e56de43954b286c5d8c152e516b0b2974 /src/libotutil | |
parent | d10593e65d504fd523ddfae5309a51ef189c841e (diff) | |
download | ostree-bb51a43d8111416bdd8225487ba803c34ad5b69b.tar.gz |
lib/core: Use GBytes for file headers
This simplifies a lot of code; the header function was structured
to write to an input stream, but many callers only wanted the checksum,
so it's simpler (and error-free) to simply allocate a whole buffer
and checksum that.
For the callers that want to write it, it's also still simpler to allocate the
buffer and write the whole thing rather than having this function do the
writing.
A lot of the complexity here again is a legacy of the packfile code, which is
dead.
This is prep for faster regfile commits where we can avoid `G{In,Out}putStream`.
Closes: #1257
Approved by: jlebon
Diffstat (limited to 'src/libotutil')
-rw-r--r-- | src/libotutil/ot-checksum-utils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libotutil/ot-checksum-utils.h b/src/libotutil/ot-checksum-utils.h index abf3c6db..2d1aa612 100644 --- a/src/libotutil/ot-checksum-utils.h +++ b/src/libotutil/ot-checksum-utils.h @@ -51,6 +51,14 @@ void ot_checksum_init (OtChecksum *checksum); void ot_checksum_update (OtChecksum *checksum, const guint8 *buf, size_t len); +static inline void +ot_checksum_update_bytes (OtChecksum *checksum, + GBytes *buf) +{ + gsize len; + const guint8 *bufdata = g_bytes_get_data (buf, &len); + ot_checksum_update (checksum, bufdata, len); +} void ot_checksum_get_digest (OtChecksum *checksum, guint8 *buf, size_t buflen); |