]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Common header file change not directly applicable to open-vm-tools.
authorOliver Kurth <okurth@vmware.com>
Tue, 27 Aug 2019 19:55:36 +0000 (12:55 -0700)
committerOliver Kurth <okurth@vmware.com>
Tue, 27 Aug 2019 19:55:36 +0000 (12:55 -0700)
open-vm-tools/lib/include/dynbuf.h

index f1a5111b773c8c459ed0244ed94c7748e2e0fc7c..61b3b3e515423a5fe89208ea93b8ec10ef72a97b 100644 (file)
@@ -252,6 +252,35 @@ DynBuf_GetAllocatedSize(DynBuf const *b) // IN
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * DynBuf_GetAvailableSize --
+ *
+ *      Returns the current available space in the dynamic buffer.
+ *
+ * Results:
+ *      Current available space in dynamic buffer
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(SWIG)
+static size_t
+#else
+static INLINE size_t
+#endif
+DynBuf_GetAvailableSize(DynBuf const *b) // IN
+{
+   ASSERT(b);
+
+   return b->allocated - b->size;
+}
+
+
 /*
  *----------------------------------------------------------------------------
  *
@@ -358,6 +387,35 @@ DynBuf_Strcat(DynBuf *buf,         // IN/OUT
 }
 
 
+/*
+ *----------------------------------------------------------------------------
+ *
+ * DynBuf_GrowToFit --
+ *
+ *      GrowToFit that dynbuf has enough room.
+ *
+ * Results:
+ *      TRUE on success
+ *      FALSE on failure (not enough memory)
+ *
+ * Side effects:
+ *      DynBuf may change its size or allocate additional memory.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+#if defined(SWIG)
+static Bool
+#else
+static INLINE Bool
+#endif
+DynBuf_GrowToFit(DynBuf *buf, // IN/OUT
+                 uint32 size) // IN
+{
+   return buf->allocated >= size ?
+      TRUE : DynBuf_Enlarge(buf, size - buf->allocated);
+}
+
 #if defined(__cplusplus)
 }  // extern "C"
 #endif