BinaryStack impl

Implements BinaryStack.

Summary
BinaryStack implImplements BinaryStack.
CopyrightThis program is free software.
Files
C-kern/api/ds/inmem/binarystack.hHeader file BinaryStack.
C-kern/ds/inmem/binarystack.cImplementation file BinaryStack impl.
blockheader_tHeader information of every allocated block.
nextPoints to previously allocated block.
sizeSize in bytes of this block.
usedsizeThe size of pushed objects stored in this block.
lifetime
query
blocksize_blockheaderReturns the size of the allocated block usable pushing objects.
usedsize_blockheaderReturns the number bytes used by pushed objects.
freesize_blockheaderReturns the number of unused bytes.
blockstart_blockheaderReturns the start address where pushed objects are stored.
header_blockheaderInverse operation to blockstart_blockheader.
headersize_blockheaderReturns the size which needs to be allocated additional.
binarystack_t
test
s_binarystack_errtimer
helper
allocateblock_binarystackAllocates a block of memory.
lifetime
change
size_binarystackThis function walks through all allocated blocks and counts the allocated size.
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

© 2012 Jörg Seebohn

Files

C-kern/api/ds/inmem/binarystack.h

Header file BinaryStack.

C-kern/ds/inmem/binarystack.c

Implementation file BinaryStack impl.

blockheader_t

struct blockheader_t

Header information of every allocated block.  This structure links a header to a previously allocated block.  And it contains some book-keeping information.

Summary
nextPoints to previously allocated block.
sizeSize in bytes of this block.
usedsizeThe size of pushed objects stored in this block.
lifetime
query
blocksize_blockheaderReturns the size of the allocated block usable pushing objects.
usedsize_blockheaderReturns the number bytes used by pushed objects.
freesize_blockheaderReturns the number of unused bytes.
blockstart_blockheaderReturns the start address where pushed objects are stored.
header_blockheaderInverse operation to blockstart_blockheader.
headersize_blockheaderReturns the size which needs to be allocated additional.

next

blockheader_t * next

Points to previously allocated block.

size

uint32_t size

Size in bytes of this block.  The start address in memory is the same as blockheader_t.

usedsize

uint32_t usedsize

The size of pushed objects stored in this block.

lifetime

query

blocksize_blockheader

static inline uint32_t blocksize_blockheader(blockheader_t *header)

Returns the size of the allocated block usable pushing objects.

usedsize_blockheader

static inline uint32_t usedsize_blockheader(blockheader_t *header)

Returns the number bytes used by pushed objects.

freesize_blockheader

static inline uint32_t freesize_blockheader(blockheader_t *header)

Returns the number of unused bytes.

blockstart_blockheader

static inline uint8_t * blockstart_blockheader(blockheader_t *header)

Returns the start address where pushed objects are stored.

header_blockheader

static inline blockheader_t * header_blockheader(uint8_t *blockstart)

Inverse operation to blockstart_blockheader.  Use it to get the address of blockheader_t computed from the value return from blockstart_blockheader.

headersize_blockheader

static inline uint32_t headersize_blockheader(void)

Returns the size which needs to be allocated additional.

binarystack_t

Summary
test
s_binarystack_errtimer
helper
allocateblock_binarystackAllocates a block of memory.
lifetime
change
size_binarystackThis function walks through all allocated blocks and counts the allocated size.
change
test

test

s_binarystack_errtimer

static test_errortimer_t s_binarystack_errtimer

helper

allocateblock_binarystack

static int allocateblock_binarystack(binarystack_t *stack,
uint32_t size)

Allocates a block of memory.  The newly allocated block is the new first entry in the list of allocated blocks.  The stack variables are adapted.

lifetime

change

size_binarystack

size_t size_binarystack(binarystack_t *stack)

This function walks through all allocated blocks and counts the allocated size.

change

test

Interface to a stack which supports objects of differing size.
Implements BinaryStack.
struct blockheader_t
Header information of every allocated block.
blockheader_t * next
Points to previously allocated block.
uint32_t size
Size in bytes of this block.
uint32_t usedsize
The size of pushed objects stored in this block.
static inline uint32_t blocksize_blockheader(blockheader_t *header)
Returns the size of the allocated block usable pushing objects.
static inline uint32_t usedsize_blockheader(blockheader_t *header)
Returns the number bytes used by pushed objects.
static inline uint32_t freesize_blockheader(blockheader_t *header)
Returns the number of unused bytes.
static inline uint8_t * blockstart_blockheader(blockheader_t *header)
Returns the start address where pushed objects are stored.
static inline blockheader_t * header_blockheader(uint8_t *blockstart)
Inverse operation to blockstart_blockheader.
static inline uint32_t headersize_blockheader(void)
Returns the size which needs to be allocated additional.
static test_errortimer_t s_binarystack_errtimer
static int allocateblock_binarystack(binarystack_t *stack,
uint32_t size)
Allocates a block of memory.
size_t size_binarystack(binarystack_t *stack)
This function walks through all allocated blocks and counts the allocated size.
Close