|
Libical API Documentation
3.0
|
Data Structures | |
| struct | buffer_ring |
Macros | |
| #define | BUFFER_RING_SIZE 2500 |
| Determines the size of the ring buffer used for keeping track of temporary buffers. | |
| #define | MIN_BUFFER_SIZE 200 |
| Determines the minimal size of buffers in the ring that are created with icalmemory_tmp_buffer(). | |
Functions | |
| void | icalmemory_add_tmp_buffer (void *buf) |
| Add an externally allocated buffer to the ring. More... | |
| void | icalmemory_append_char (char **buf, char **pos, size_t *buf_size, char ch) |
| Append a character to a buffer. More... | |
| void | icalmemory_append_string (char **buf, char **pos, size_t *buf_size, const char *string) |
| Append a string to a buffer. More... | |
| void | icalmemory_free_buffer (void *buf) |
| Releases a buffer. More... | |
| void | icalmemory_free_ring () |
| Free all memory used in the ring. More... | |
| void * | icalmemory_new_buffer (size_t size) |
| Creates new buffer with the specified size. More... | |
| void * | icalmemory_resize_buffer (void *buf, size_t size) |
| Resizes a buffer created with icalmemory_new_buffer(). More... | |
| char * | icalmemory_strdup (const char *s) |
| Create a duplicate of a string. More... | |
| void * | icalmemory_tmp_buffer (size_t size) |
| Creates a new temporary buffer on the ring and returns it. More... | |
| char * | icalmemory_tmp_copy (const char *str) |
| Creates a copy of the given string, stored on the ring buffer, and returns it. More... | |
| void icalmemory_add_tmp_buffer | ( | void * | buf | ) |
Add an externally allocated buffer to the ring.
| buf | The externally allocated buffer to add to the ring |
Adds an externally allocated buffer to the ring. This ensures that libical will free() the buffer automatically, either after BUFFER_RING_SIZE other buffers have been created or added, or after icalmemory_free_ring() has been called.
NULL.free()d manually anymore, it leads to a double-free() when icalmemory reclaims the memory.| void icalmemory_append_char | ( | char ** | buf, |
| char ** | pos, | ||
| size_t * | buf_size, | ||
| char | ch | ||
| ) |
Append a character to a buffer.
| buf | The buffer to append the character to. |
| pos | The position to append the character at. |
| buf_size | The size of the buffer (will be changed if buffer is reallocated) |
| ch | The character to append to the buffer. This method may not be used for temporary buffers (buffers allocated with icalmemory_tmp_buffer() and related functions)! |
*buf, pos, * pos, or buf_size NULL.This method will copy the character ch and a ‘’\0'` character after it to the buffer buf starting at position pos, reallocing buf if it is too small. buf_size is the size of buf and will be changed if buf is reallocated. pos will point to the new terminating ‘’\0'` character buf.
| void icalmemory_append_string | ( | char ** | buf, |
| char ** | pos, | ||
| size_t * | buf_size, | ||
| const char * | string | ||
| ) |
Append a string to a buffer.
| buf | The buffer to append the string to. |
| pos | The position to append the string at. |
| buf_size | The size of the buffer (will be changed if buffer is reallocated) |
| string | The string to append to the buffer. This method may not be used for temporary buffers (buffers allocated with icalmemory_tmp_buffer() and related functions)! |
*buf, pos, * pos, buf_size or string are NULL.This method will copy the string string to the buffer buf starting at position pos, reallocing buf if it is too small. buf_size is the size of buf and will be changed if buf is reallocated. pos will point to the last byte of the new string in buf, usually a ‘’\0'`
| void icalmemory_free_buffer | ( | void * | buf | ) |
Releases a buffer.
| buf | The buffer to release |
Releases the memory of the buffer.
| void icalmemory_free_ring | ( | void | ) |
Free all memory used in the ring.
Frees all memory used in the ring. Depending on if ::HAVE_PTHREAD is set or not, the ring buffer is allocated on a per-thread basis, meaning that if all rings are to be released, it must be called once in every thread.
| void* icalmemory_new_buffer | ( | size_t | size | ) |
Creates new buffer with the specified size.
| size | The size of the buffer that is to be created. |
NULL.This creates a new (non-temporary) buffer of the specified size. All buffers returned by this method are zeroed-out.
| void* icalmemory_resize_buffer | ( | void * | buf, |
| size_t | size | ||
| ) |
Resizes a buffer created with icalmemory_new_buffer().
| buf | The buffer to be resized. |
| size | The new size of the buffer. |
NULL.| char* icalmemory_strdup | ( | const char * | s | ) |
Create a duplicate of a string.
| s | The string to duplicate. |
NULL, otherwise depending on the libc used, it might lead to undefined behaviour (read: segfaults).free() method.A wrapper around strdup(). Partly to trap calls to strdup(), partly because in -ansi, gcc on Red Hat claims that strdup() is undeclared.
| void* icalmemory_tmp_buffer | ( | size_t | size | ) |
Creates a new temporary buffer on the ring and returns it.
| size | How big (in bytes) the buffer should be |
Creates a temporary buffer on the ring. Regardless of what size you specify, the buffer will always be at least MIN_BUFFER_SIZE big, and it will be zeroed out.
NULL.| char* icalmemory_tmp_copy | ( | const char * | str | ) |
Creates a copy of the given string, stored on the ring buffer, and returns it.
| str | The string to copy |
NULL, otherwise a segfault might ensue, since the routine calls strlen() on it.
1.8.14