From 9b13289a2aedc01faaff483fae8a59c73da8d321 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 10 Sep 2022 12:31:50 -0700 Subject: [PATCH] cgraph agxbuf: relocate 'agxblen' A number of other functions in agxbuf.h open code the logic of `agxblen`. Moving this function higher in the header will enable us to de-duplicate this code. The goal here is to fully abstract this, as an upcoming commit will make the way the length of an `agxbuf` is calculated conditional. Gitlab: #2302 --- lib/cgraph/agxbuf.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/cgraph/agxbuf.h b/lib/cgraph/agxbuf.h index 78baaf3c6..e902ccbda 100644 --- a/lib/cgraph/agxbuf.h +++ b/lib/cgraph/agxbuf.h @@ -54,6 +54,13 @@ static inline void agxbfree(agxbuf *xb) { free(xb->buf); } +/* agxblen: + * Return number of characters currently stored. + */ +static inline size_t agxblen(const agxbuf *xb) { + return (size_t)(xb->ptr - xb->buf); +} + /* agxbpop: * Removes last character added, if any. */ @@ -193,13 +200,6 @@ static inline char *agxbuse(agxbuf *xb) { return xb->ptr; } -/* agxblen: - * Return number of characters currently stored. - */ -static inline size_t agxblen(const agxbuf *xb) { - return (size_t)(xb->ptr - xb->buf); -} - /* agxbclear: * Resets pointer to data; */ -- 2.40.0