BRL-CAD
Variable-length Byte Buffers

The variable length buffer package. More...

Collaboration diagram for Variable-length Byte Buffers:

Files

file  vlb.h
 

Data Structures

struct  bu_vlb
 

Macros

#define BU_VLB_NULL   ((struct bu_vlb *)0)
 
#define BU_CK_VLB(_vp)   BU_CKMAG(_vp, BU_VLB_MAGIC, "bu_vlb")
 
#define BU_VLB_INIT(_vp)
 
#define BU_VLB_INIT_ZERO   { BU_VLB_MAGIC, NULL, 0, 0 }
 
#define BU_VLB_IS_INITIALIZED(_vp)   (((struct bu_vlb *)(_vp) != BU_VLB_NULL) && ((_vp)->magic == BU_VLB_MAGIC))
 

Typedefs

typedef struct bu_vlb bu_vlb_t
 

Functions

void bu_vlb_init (struct bu_vlb *vlb)
 
void bu_vlb_initialize (struct bu_vlb *vlb, size_t initialSize)
 
void bu_vlb_write (struct bu_vlb *vlb, unsigned char *start, size_t len)
 
void bu_vlb_reset (struct bu_vlb *vlb)
 
unsigned char * bu_vlb_addr (struct bu_vlb *vlb)
 
size_t bu_vlb_buflen (struct bu_vlb *vlb)
 
void bu_vlb_free (struct bu_vlb *vlb)
 
void bu_vlb_print (struct bu_vlb *vlb, FILE *fd)
 
void bu_pr_vlb (const char *title, const struct bu_vlb *vlb)
 

Detailed Description

The variable length buffer package.

Macro Definition Documentation

◆ BU_VLB_NULL

#define BU_VLB_NULL   ((struct bu_vlb *)0)

Definition at line 52 of file vlb.h.

◆ BU_CK_VLB

#define BU_CK_VLB (   _vp)    BU_CKMAG(_vp, BU_VLB_MAGIC, "bu_vlb")

assert the integrity of a bu_vlb struct.

Definition at line 57 of file vlb.h.

◆ BU_VLB_INIT

#define BU_VLB_INIT (   _vp)
Value:
{ \
(_vp)->magic = BU_VLB_MAGIC; \
(_vp)->buf = NULL; \
(_vp)->bufCapacity = (_vp)->nextByte = 0; \
}
#define BU_VLB_MAGIC
Definition: magic.h:73

initializes a bu_vlb struct without allocating any memory.

Definition at line 62 of file vlb.h.

◆ BU_VLB_INIT_ZERO

#define BU_VLB_INIT_ZERO   { BU_VLB_MAGIC, NULL, 0, 0 }

macro suitable for declaration statement initialization of a bu_vlb struct. does not allocate memory.

Definition at line 72 of file vlb.h.

◆ BU_VLB_IS_INITIALIZED

#define BU_VLB_IS_INITIALIZED (   _vp)    (((struct bu_vlb *)(_vp) != BU_VLB_NULL) && ((_vp)->magic == BU_VLB_MAGIC))

returns truthfully whether a bu_vlb struct has been initialized. is not reliable unless the struct has been allocated with BU_ALLOC(), bu_calloc(), or a previous call to bu_vlb_init() or BU_VLB_INIT() has been made.

Definition at line 80 of file vlb.h.

Typedef Documentation

◆ bu_vlb_t

typedef struct bu_vlb bu_vlb_t

Definition at line 51 of file vlb.h.

Function Documentation

◆ bu_vlb_init()

void bu_vlb_init ( struct bu_vlb vlb)

Initialize the specified bu_vlb structure and mallocs the initial block of memory.

Parameters
vlbPointer to an uninitialized bu_vlb structure

◆ bu_vlb_initialize()

void bu_vlb_initialize ( struct bu_vlb vlb,
size_t  initialSize 
)

Initialize the specified bu_vlb structure and mallocs the initial block of memory with the specified size

Parameters
vlbPointer to an uninitialized bu_vlb structure
initialSizeThe desired initial size of the buffer

◆ bu_vlb_write()

void bu_vlb_write ( struct bu_vlb vlb,
unsigned char *  start,
size_t  len 
)

Write some bytes to the end of the bu_vlb structure. If necessary, additional memory will be allocated.

Parameters
vlbPointer to the bu_vlb structure to receive the bytes
startPointer to the first byte to be copied to the bu_vlb structure
lenThe number of bytes to copy to the bu_vlb structure

◆ bu_vlb_reset()

void bu_vlb_reset ( struct bu_vlb vlb)

Reset the bu_vlb counter to the start of its byte array. This essentially ignores any bytes currently in the buffer, but does not free any memory.

Parameters
vlbPointer to the bu_vlb structure to be reset

◆ bu_vlb_addr()

unsigned char * bu_vlb_addr ( struct bu_vlb vlb)

Get a pointer to the byte array held by the bu_vlb structure

Parameters
vlbPointer to the bu_vlb structure
Returns
A pointer to the byte array contained by the bu_vlb structure

◆ bu_vlb_buflen()

size_t bu_vlb_buflen ( struct bu_vlb vlb)

Return the number of bytes used in the bu_vlb structure

Parameters
vlbPointer to the bu_vlb structure
Returns
The number of bytes written to the bu_vlb structure

◆ bu_vlb_free()

void bu_vlb_free ( struct bu_vlb vlb)

Free the memory allocated for the byte array in the bu_vlb structure. Also uninitializes the structure.

Parameters
vlbPointer to the bu_vlb structure

◆ bu_vlb_print()

void bu_vlb_print ( struct bu_vlb vlb,
FILE *  fd 
)

Write the current byte array from the bu_vlb structure to a file

Parameters
vlbPointer to the bu_vlb structure that is the source of the bytes
fdPointer to a FILE to receive the bytes

◆ bu_pr_vlb()

void bu_pr_vlb ( const char *  title,
const struct bu_vlb vlb 
)

Print the bytes set in a variable-length byte array.