Libical API Documentation  3.0
icalmemory.h
Go to the documentation of this file.
1 /*======================================================================
2  FILE: icalmemory.h
3  CREATOR: eric 30 June 1999
4 
5  (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com>
6 
7  This library is free software; you can redistribute it and/or modify
8  it under the terms of either:
9 
10  The LGPL as published by the Free Software Foundation, version
11  2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html
12 
13  Or:
14 
15  The Mozilla Public License Version 2.0. You may obtain a copy of
16  the License at https://www.mozilla.org/MPL/
17 
18  The Initial Developer of the Original Code is Eric Busboom
19 ======================================================================*/
20 
21 #ifndef ICALMEMORY_H
22 #define ICALMEMORY_H
23 
45 #include "libical_ical_export.h"
46 
73 LIBICAL_ICAL_EXPORT void *icalmemory_tmp_buffer(size_t size);
74 
97 LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str);
98 
123 LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf);
124 
142 LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void);
143 
144 /* Non-tmp buffers must be freed. These are mostly wrappers around
145  * malloc, etc, but are used so the caller can change the memory
146  * allocators in a future version of the library */
147 
177 LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size);
178 
215 LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size);
216 
224 LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf);
225 
226 /* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
227  normally allocated memory, or on buffers created from
228  icalmemory_new_buffer, never with buffers created by
229  icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
230  buffer on the ring, the ring will loose track of it an you will
231  have memory problems. */
232 
271 LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t *buf_size,
272  const char *string);
273 
313 LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch);
314 
339 LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s);
340 
341 #endif /* !ICALMEMORY_H */
icalmemory_strdup
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition: icalmemory.c:251
icalmemory_free_buffer
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition: icalmemory.c:287
icalmemory_tmp_buffer
void * icalmemory_tmp_buffer(size_t size)
Creates a new temporary buffer on the ring and returns it.
Definition: icalmemory.c:205
icalmemory_free_ring
void icalmemory_free_ring(void)
Frees all memory used in the ring.
Definition: icalmemory.c:227
icalmemory_append_char
void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch)
Appends a character to a buffer.
Definition: icalmemory.c:330
icalmemory_add_tmp_buffer
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition: icalmemory.c:182
icalmemory_new_buffer
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition: icalmemory.c:261
icalmemory_resize_buffer
void * icalmemory_resize_buffer(void *buf, size_t size)
Resizes a buffer created with icalmemory_new_buffer().
Definition: icalmemory.c:275
icalmemory_tmp_copy
char * icalmemory_tmp_copy(const char *str)
Creates a copy of the given string, stored on the ring buffer, and returns it.
Definition: icalmemory.c:242
icalmemory_append_string
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
Definition: icalmemory.c:292