libstring
simple flexible string manipulation library
 All Data Structures Files Functions Variables Typedefs Macros
Functions | Variables
libstring.c File Reference

All functions in libstring. More...

#include "libstring.h"

Functions

string string_new ()
 
uint16_t string_bavail (string a)
 
string string_realloc (string a, uint16_t minS)
 
string string_copy (string a, const string b, uint16_t offset, uint16_t num)
 
string string_dup (const string a)
 
string string_temporary (string in)
 
string string_mknew (const string_unit *in)
 
string string_appendv (int count,...)
 

Variables

uint16_t allocS [] = {16, 32, 64, 256, 512, 1024, 2048, 4096, 8192, 12288, 0}
 

Detailed Description

All functions in libstring.

Function Documentation

string string_appendv ( int  count,
  ... 
)

Append a variable number of strings

Returns
pointer to the new string
uint16_t string_bavail ( string  a)

Get the number of bytes available in the string

Returns
the number of bytes available
string string_copy ( string  a,
const string  b,
uint16_t  offset,
uint16_t  num 
)

Copy num characters from string B to A with offset offset.

if num is 0, then all characters will be copied.

a string #1 b string #2 offset offset num number

Returns
the new string (guaranteed to be library-compatible string)
string string_dup ( const string  a)

Make a duplicate of a string

a string

Returns
the copy of the string (guaranteed to be library-compatible string)
string string_mknew ( const string_unit in)

Duplicate a non-library string

Use this function if you are concerned about reads before the string

string string_new ( )

Create a new string

Returns
pointer to the new string
string string_realloc ( string  a,
uint16_t  minS 
)

Reallocate string A with minimum size

a the string to reallocate minS the minimum size of the string

Returns
pointer to the new string
string string_temporary ( string  in)

Declare a string as temporary, ie, that it will be freed right after use

If the string is not library-compatible, nothing happens.

Returns
the pointer to the string

Variable Documentation

uint16_t allocS[] = {16, 32, 64, 256, 512, 1024, 2048, 4096, 8192, 12288, 0}

Allocation sizes by default
Each one is ~double the previous one

The 0 just means allocate as much as needed, no extras