]> granicus.if.org Git - graphviz/commitdiff
cgraph agxbuf: relocate 'agxblen'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Sep 2022 19:31:50 +0000 (12:31 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Sep 2022 19:33:33 +0000 (12:33 -0700)
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.

lib/cgraph/agxbuf.h

index c6779e01b2a159f1ce83b855b86d1ebd5a5c24a2..f7066eef39e46bb707005b2b519cbf9ae77339e6 100644 (file)
@@ -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;
  */