Home
Highly Reusable Software By activity User Interface Text Strings Math Processing
Stored Data
Communications
Hard World File System
|
librock_VSBsz - Ensure '\0' follows the buffer, and return pointer to buffer.
librock_VSBfree - deallocate storage associated with a librock_VSB
#License - #Source code - #Example Use -
#include <librock/mstruct.h> struct librock_VSB_s * librock_VSBalloc(); struct librock_VSB_s * librock_VSBallocXA( const void *p, int len ); struct librock_VSB_s * librock_VSBalloccpy( const void *ptr, int len ); void librock_VSBfree( struct librock_VSB_s *v ); char * librock_VSBsz( struct librock_VSB_s *v );
Memory is obtained from malloc(), but callers must use the librock_VSB routines to manage the VSB.
The allocated buffer size can be up to INT_MAX. Callers can access the structure members "buf" (pointer) and "inbuf" (count of bytes) but should never change them.
Use librock_VSBallocXA() to create a librock_VSB structure which describes a buffer already externally allocated. It will be "WriteDisabled."
Use librock_VSBalloccpy() to create a librock_VSB structure and copy in data initially.
Use librock_VSBrealloc() to resize a buffer. The VSB.inbuf member is not changed. Returns 0 if memory realloc fails.
Typical use is to create a workspace for data, especially non-string data. librock_VSB_s is useful as a primitive in the implementation of other basic data structures, such as lists of pointers, or structures.
#ifdef librock_TYPICAL_USE_VSBalloc #include <librock/mstruct.h> struct librock_VSB_s *v = librock_VSBalloc(); librock_VSBAppend(v,"is ",3); librock_VSBInsert(v,0,"this ",5); printf("%s\n",librock_VSBsz(v)); librock_VSBfree(v); #endifFor C++ uses, see the librock_CVsb wrapper class. See also the librock_VSIL_s routines.
malloc() // #ifndef librock_fmalloc realloc() // #ifndef librock_fmalloc free() // #ifndef librock_fmalloc memcpy() // #ifndef librock_memcpy memmove() // #ifndef librock_memcpy memset() // #ifndef librock_memcpy // Uses macros for memory operations librock_fmalloc // librock_ffree librock_frealloc librock_memcpy librock_memmove // and librock_memset. If those macros are not defined at // compile time, they are set to use malloc(), realloc(), // free(), memcpy(), memmove(), and memset()
Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45
librock_VSBalloc passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_VSBalloc passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_VSBallocXA passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_VSBallocXA passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_VSBalloccpy passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_VSBalloccpy passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_VSBfree passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_VSBfree passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_VSBsz passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_VSBsz passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)
Want to help? We welcome comments, patches. -- Need help? Request paid support.