libUPnP
1.6.17
|
Go to the source code of this file.
Data Structures | |
struct | memptr |
struct | membuffer |
Defines | |
#define | MINVAL(a, b) ( (a) < (b) ? (a) : (b) ) |
#define | MAXVAL(a, b) ( (a) > (b) ? (a) : (b) ) |
#define | MEMBUF_DEF_SIZE_INC (size_t)5 |
Functions | |
char * | str_alloc (const char *str, size_t str_len) |
Allocate memory and copy information from the input string to the newly allocated memory. | |
int | memptr_cmp (memptr *m, const char *s) |
Compares characters of strings passed for number of bytes. If equal for the number of bytes, the length of the bytes determines which buffer is shorter. | |
int | memptr_cmp_nocase (memptr *m, const char *s) |
Compares characters of 2 strings irrespective of the case for a specific count of bytes. | |
int | membuffer_set_size (membuffer *m, size_t new_length) |
Increases or decreases buffer cap so that at least 'new_length' bytes can be stored. | |
void | membuffer_init (membuffer *m) |
Wrapper to membuffer_initialize(). | |
void | membuffer_destroy (membuffer *m) |
Free's memory allocated for membuffer* m. | |
int | membuffer_assign (membuffer *m, const void *buf, size_t buf_len) |
Allocate memory to membuffer *m and copy the contents of the in parameter const void *buf. | |
int | membuffer_assign_str (membuffer *m, const char *c_str) |
Wrapper function for membuffer_assign(). | |
int | membuffer_append (membuffer *m, const void *buf, size_t buf_len) |
Invokes function to appends data from a constant buffer to the buffer. | |
int | membuffer_append_str (membuffer *m, const char *c_str) |
Invokes function to appends data from a constant string to the buffer. | |
int | membuffer_insert (membuffer *m, const void *buf, size_t buf_len, size_t index) |
Allocates memory for the new data to be inserted. Does memory management by moving the data from the existing memory to the newly allocated memory and then appending the new data. | |
void | membuffer_delete (membuffer *m, size_t index, size_t num_bytes) |
Shrink the size of the buffer depending on the current size of the bufer and te input parameters. Move contents from the old buffer to the new sized buffer. | |
char * | membuffer_detach (membuffer *m) |
void | membuffer_attach (membuffer *m, char *new_buf, size_t buf_len) |
#define MEMBUF_DEF_SIZE_INC (size_t)5 |
default value of size_inc.
Referenced by ixml_membuf_init(), and membuffer_init().
int membuffer_append | ( | membuffer * | m, |
const void * | buf, | ||
size_t | buf_len | ||
) |
Invokes function to appends data from a constant buffer to the buffer.
[in,out] | m | Buffer whose memory is to be appended. |
[in] | buf | Source buffer whose contents will be copied. |
[in] | buf_len | Length of the source buffer. |
References membuffer::length.
int membuffer_append_str | ( | membuffer * | m, |
const char * | c_str | ||
) |
Invokes function to appends data from a constant string to the buffer.
[in,out] | m | Buffer whose memory is to be appended. |
[in] | c_str | Source buffer whose contents will be copied. |
References membuffer::length.
int membuffer_assign | ( | membuffer * | m, |
const void * | buf, | ||
size_t | buf_len | ||
) |
Allocate memory to membuffer *m and copy the contents of the in parameter const void *buf.
[in,out] | m | Buffer whose memory is to be allocated and assigned. |
[in] | buf | Source buffer whose contents will be copied. |
[in] | buf_len | Length of the source buffer. |
References membuffer::buf, and membuffer::length.
int membuffer_assign_str | ( | membuffer * | m, |
const char * | c_str | ||
) |
Wrapper function for membuffer_assign().
[in,out] | m | Buffer to be allocated and assigned. |
[in] | c_str | Source buffer whose contents will be copied. |
void membuffer_attach | ( | membuffer * | m, |
char * | new_buf, | ||
size_t | buf_len | ||
) |
[in,out] | m | Buffer to be updated. |
[in] | new_buf | Source buffer which will be assigned to the buffer to be updated. |
[in] | buf_len | Length of the source buffer. |
References membuffer::buf, membuffer::capacity, and membuffer::length.
void membuffer_delete | ( | membuffer * | m, |
size_t | index, | ||
size_t | num_bytes | ||
) |
Shrink the size of the buffer depending on the current size of the bufer and te input parameters. Move contents from the old buffer to the new sized buffer.
[in,out] | m | Buffer whose memory size is to be decreased and copied to the modified location. |
[in] | index | Index to determine bounds while moving data. |
[in] | num_bytes | Number of bytes that the data needs to shrink by. |
References membuffer::buf, and membuffer::length.
void membuffer_destroy | ( | membuffer * | m | ) |
Free's memory allocated for membuffer* m.
[in,out] | m | Buffer to be destroyed. |
References membuffer::buf.
char* membuffer_detach | ( | membuffer * | m | ) |
[in,out] | m | Buffer to be returned and updated. |
References membuffer::buf.
void membuffer_init | ( | membuffer * | m | ) |
Wrapper to membuffer_initialize().
Set the size of the buffer to MEMBUF_DEF_SIZE_INC and Initializes m->buf to NULL, length = 0.
[in,out] | m | Buffer to be initialized. |
References MEMBUF_DEF_SIZE_INC, and membuffer::size_inc.
int membuffer_insert | ( | membuffer * | m, |
const void * | buf, | ||
size_t | buf_len, | ||
size_t | index | ||
) |
Allocates memory for the new data to be inserted. Does memory management by moving the data from the existing memory to the newly allocated memory and then appending the new data.
[in,out] | m | Buffer whose memory size is to be increased and appended. |
[in] | buf | source buffer whose contents will be copied. |
[in] | buf_len | size of the source buffer. |
[in] | index | index to determine the bounds while movinf the data. |
References membuffer::buf, and membuffer::length.
int membuffer_set_size | ( | membuffer * | m, |
size_t | new_length | ||
) |
Increases or decreases buffer cap so that at least 'new_length' bytes can be stored.
[in,out] | m | buffer whose size is to be modified. |
[in] | new_length | new size to which the buffer will be modified. |
References membuffer::buf, membuffer::capacity, membuffer::length, membuffer::size_inc, and UPNP_E_OUTOF_MEMORY.
int memptr_cmp | ( | memptr * | m, |
const char * | s | ||
) |
Compares characters of strings passed for number of bytes. If equal for the number of bytes, the length of the bytes determines which buffer is shorter.
[in] | m | Input memory object. |
[in] | s | Constatnt string for the memory object to be compared with. |
References memptr::buf, and memptr::length.
int memptr_cmp_nocase | ( | memptr * | m, |
const char * | s | ||
) |
Compares characters of 2 strings irrespective of the case for a specific count of bytes.
If the character comparison is the same the length of the 2 srings determines the shorter of the 2 strings.
[in] | m | Input memory object. |
[in] | s | Constatnt string for the memory object to be compared with. |
References memptr::buf, and memptr::length.
char* str_alloc | ( | const char * | str, |
size_t | str_len | ||
) |
Allocate memory and copy information from the input string to the newly allocated memory.
[in] | str | Input string object. |
[in] | str_len | Input string length. |