38 static const size_t CNUnitSizeOfBuffer = 512 ;
40 size_t s0 = (size + CNUnitSizeOfBuffer - 1) / CNUnitSizeOfBuffer ;
41 return s0 * CNUnitSizeOfBuffer ;
43 return CNUnitSizeOfBuffer ;
114 static inline const void *
130 size_t nextpos = writepos + srcsize ;
136 unsigned char * dstptr = &(dst->
context[writepos]) ;
137 memcpy(dstptr, srcptr, srcsize) ;
Write buffer to store variable-sized continuous data.
Definition: CNBuffer.h:17
static void CNPutBytesToBuffer(struct CNBuffer *dst, size_t srcsize, const void *srcptr)
Write byte data into the buffer.
Definition: CNBuffer.h:127
static size_t CNCalcSizeOfBuffer(size_t size)
Calc memory size of CNBuffer.
Definition: CNBuffer.h:36
static void CNResetBuffer(struct CNBuffer *dst)
Make the buffer empty.
Definition: CNBuffer.h:74
static void CNDestroyBuffer(struct CNBuffer *dst)
Destroy the context of CNBuffer.
Definition: CNBuffer.h:64
size_t writePosition
Current size of the buffer.
Definition: CNBuffer.h:20
static size_t CNSizeOfBuffer(const struct CNBuffer *src)
Get the size of valid data in CNBuffer.
Definition: CNBuffer.h:104
static void CNInitBuffer(struct CNBuffer *dst)
Initialize CNBuffer object.
Definition: CNBuffer.h:52
size_t currentSize
The position to put the next data.
Definition: CNBuffer.h:22
unsigned char * context
Pointer for the buffer context.
Definition: CNBuffer.h:24
static void * CNDetachDataFromBuffer(struct CNBuffer *dst)
Detach context from the buffer.
Definition: CNBuffer.h:89
static const void * CNContextOfBuffer(const struct CNBuffer *src)
Get the context of CNBuffer.
Definition: CNBuffer.h:115