Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

dstring.h File Reference

Go to the source code of this file.

Data Structures

struct  s_dstring
 Data structure that defines a dynamic string. More...


Typedefs

typedef s_dstring dstring
 Data type for dynamic string.


Functions

int dstring_init (dstring *s, size_t init_size)
 Initialize a dynamic string.

void dstring_free (dstring *s)
 Free all memory allocated for a dynamic string.

int dstring_add (dstring *s, char *buff, size_t nb_elem)
 Add characters into a given dynamic string.

char * dstring_get_data (dstring *s, size_t *size)
 Return the content of a dynamic string.


Detailed Description

Header file for dstring.c

Definition in file dstring.h.


Function Documentation

int dstring_add dstring   s,
char *    buff,
size_t    nb_elem
 

Add characters into a given dynamic string.

Parameters:
s Pointer to a given dynamic string.
buff Pointer to a buffer that contains the characters to add to the dynamic string.
nb_elem Number of characters to add.
Returns:
Upon successful completion, the function returns 0. Otherwise the function returns 1 (this means that the process is running out of memory.
Warning:
You MUST initialize a dynamic string (using dstring_init()), before you can add data into it.

Definition at line 61 of file dstring.c.

References s_dstring::data, s_dstring::nb_car, and s_dstring::size.

Referenced by replace_tags().

void dstring_free dstring   s
 

Free all memory allocated for a dynamic string.

Parameters:
s Pointer to a given dynamic string.

Definition at line 40 of file dstring.c.

References s_dstring::data, s_dstring::nb_car, and s_dstring::size.

Referenced by replace_tags().

char* dstring_get_data dstring   s,
size_t *    size
 

Return the content of a dynamic string.

Parameters:
s Pointer to a given dynamic string.
size pointer to a size_t value that will be used to store the number of bytes extracted from the dynamic string.
Returns:
Upon successful completion, the function returns a pointer to a dynamically allocated buffer that contains the dynamic string's data. The value pointed by size represents the number of bytes allocated for the returned string (including the final 0). If the function could not allocate memory, then it returns NULL.
Warning:
The returned pointer points to a memory location that has been allocated within the function. Therefore you should free it (using free()) when you don't need it anymore.

Definition at line 98 of file dstring.c.

References s_dstring::data, and s_dstring::nb_car.

Referenced by replace_tags().

int dstring_init dstring   s,
size_t    init_size
 

Initialize a dynamic string.

Parameters:
s Pointer to a given dynamic string.
init_size Initial size of the dynamic string.
Returns:
Upon successful completion, the function returns 0. Otherwise the function returns 1 (this means that the process is running out of memory.
Warning:
You MUST initialize a dynamic string (using dstring_init()), before you can do any operation on it.

Definition at line 21 of file dstring.c.

References s_dstring::data, s_dstring::nb_car, and s_dstring::size.

Referenced by replace_tags().


Generated on Thu Apr 3 16:23:45 2003 for Common_C_libraries by doxygen1.3-rc1