From: Matthew Fernandez Date: Sat, 10 Sep 2022 19:31:50 +0000 (-0700) Subject: cgraph agxbuf: relocate 'agxblen' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ca856ba54de110c14fd0ad843731f25c3e077da;p=graphviz 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. --- diff --git a/lib/cgraph/agxbuf.h b/lib/cgraph/agxbuf.h index c6779e01b..f7066eef3 100644 --- a/lib/cgraph/agxbuf.h +++ b/lib/cgraph/agxbuf.h @@ -60,6 +60,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. */ @@ -204,13 +211,6 @@ static inline char *agxbuse(agxbuf *xb) { */ static inline char *agxbstart(agxbuf *xb) { return xb->buf; } -/* 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; */