From: Oliver Kurth Date: Tue, 27 Aug 2019 19:55:36 +0000 (-0700) Subject: Common header file change not directly applicable to open-vm-tools. X-Git-Tag: stable-11.1.0~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a29dd522b3ee667279b9a8a1a7c1655ef2f12839;p=thirdparty%2Fopen-vm-tools.git Common header file change not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/dynbuf.h b/open-vm-tools/lib/include/dynbuf.h index f1a5111b7..61b3b3e51 100644 --- a/open-vm-tools/lib/include/dynbuf.h +++ b/open-vm-tools/lib/include/dynbuf.h @@ -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