WriteBuffer impl

Implements WriteBuffer.

Summary
WriteBuffer implImplements WriteBuffer.
CopyrightThis program is free software.
Files
C-kern/api/memory/wbuffer.hHeader file WriteBuffer.
C-kern/memory/wbuffer.cImplementation file WriteBuffer impl.
wbuffer_t
static variables
s_wbuffer_errtimerSimulates an error in <reserve_memblock_wbuffer> and <reserve_cstring_wbuffer>.
interface implementation
alloc_cstring_wbufferResizes cstring_t if necessary and returns additional memory in memstr.
shrink_cstring_wbufferSets memstr to whole allocated buffer of impl (cstring_t) except for the first new_size bytes.
size_cstring_wbufferReturns size in use of impl (cstring_t).
alloc_memblock_wbufferResizes memblock_t if necessary and returns additional memory in memstr.
shrink_memblock_wbufferSets memstr to whole allocated buffer of impl (memblock_t) except for the first new_size bytes.
size_memblock_wbufferReturns number of appended bytes of impl (memblock_t).
alloc_static_wbufferReturns always ENOMEM.
shrink_static_wbufferSets wbuf->next to start+new_size of static buffer.
size_static_wbufferReturns number of appended bytes.
global variables
change
test

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/memory/wbuffer.h

Header file WriteBuffer.

C-kern/memory/wbuffer.c

Implementation file WriteBuffer impl.

wbuffer_t

Summary
static variables
s_wbuffer_errtimerSimulates an error in <reserve_memblock_wbuffer> and <reserve_cstring_wbuffer>.
interface implementation
alloc_cstring_wbufferResizes cstring_t if necessary and returns additional memory in memstr.
shrink_cstring_wbufferSets memstr to whole allocated buffer of impl (cstring_t) except for the first new_size bytes.
size_cstring_wbufferReturns size in use of impl (cstring_t).
alloc_memblock_wbufferResizes memblock_t if necessary and returns additional memory in memstr.
shrink_memblock_wbufferSets memstr to whole allocated buffer of impl (memblock_t) except for the first new_size bytes.
size_memblock_wbufferReturns number of appended bytes of impl (memblock_t).
alloc_static_wbufferReturns always ENOMEM.
shrink_static_wbufferSets wbuf->next to start+new_size of static buffer.
size_static_wbufferReturns number of appended bytes.
global variables
change
test

static variables

s_wbuffer_errtimer

static test_errortimer_t s_wbuffer_errtimer

Simulates an error in <reserve_memblock_wbuffer> and <reserve_cstring_wbuffer>.

interface implementation

alloc_cstring_wbuffer

static int alloc_cstring_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)

Resizes cstring_t if necessary and returns additional memory in memstr.

shrink_cstring_wbuffer

static int shrink_cstring_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)

Sets memstr to whole allocated buffer of impl (cstring_t) except for the first new_size bytes.

size_cstring_wbuffer

static size_t size_cstring_wbuffer(void *impl,
const memstream_t *memstr)

Returns size in use of impl (cstring_t).

alloc_memblock_wbuffer

static int alloc_memblock_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)

Resizes memblock_t if necessary and returns additional memory in memstr.

shrink_memblock_wbuffer

static int shrink_memblock_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)

Sets memstr to whole allocated buffer of impl (memblock_t) except for the first new_size bytes.

size_memblock_wbuffer

static size_t size_memblock_wbuffer(void *impl,
const memstream_t *memstr)

Returns number of appended bytes of impl (memblock_t).

alloc_static_wbuffer

static int alloc_static_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)

Returns always ENOMEM.

shrink_static_wbuffer

static int shrink_static_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)

Sets wbuf->next to start+new_size of static buffer.

size_static_wbuffer

static size_t size_static_wbuffer(void *impl,
const memstream_t *memstr)

Returns number of appended bytes.

global variables

change

test

Implements a simple write buffer.
Implements WriteBuffer.
static test_errortimer_t s_wbuffer_errtimer
Simulates an error in reserve_memblock_wbuffer and reserve_cstring_wbuffer.
static int alloc_cstring_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)
Resizes cstring_t if necessary and returns additional memory in memstr.
struct cstring_t
Dynamically growing C string with trailing ‘\0’ byte.
static int shrink_cstring_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)
Sets memstr to whole allocated buffer of impl (cstring_t) except for the first new_size bytes.
static size_t size_cstring_wbuffer(void *impl,
const memstream_t *memstr)
Returns size in use of impl (cstring_t).
static int alloc_memblock_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)
Resizes memblock_t if necessary and returns additional memory in memstr.
struct memblock_t
Describes memory block.
static int shrink_memblock_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)
Sets memstr to whole allocated buffer of impl (memblock_t) except for the first new_size bytes.
static size_t size_memblock_wbuffer(void *impl,
const memstream_t *memstr)
Returns number of appended bytes of impl (memblock_t).
static int alloc_static_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)
Returns always ENOMEM.
static int shrink_static_wbuffer(void *impl,
size_t new_size,
/*inout*/memstream_t *memstr)
Sets wbuf->next to start+new_size of static buffer.
static size_t size_static_wbuffer(void *impl,
const memstream_t *memstr)
Returns number of appended bytes.
Close