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@softwarestudio.org>
6  http://www.softwarestudio.org
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of either:
10 
11  The LGPL as published by the Free Software Foundation, version
12  2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
13 
14  Or:
15 
16  The Mozilla Public License Version 2.0. You may obtain a copy of
17  the License at http://www.mozilla.org/MPL/
18 
19  The Initial Developer of the Original Code is Eric Busboom
20 ======================================================================*/
21 
22 #ifndef ICALMEMORY_H
23 #define ICALMEMORY_H
24 
46 #include "libical_ical_export.h"
47 
74 LIBICAL_ICAL_EXPORT void *icalmemory_tmp_buffer(size_t size);
75 
98 LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str);
99 
124 LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf);
125 
143 LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void);
144 
145 /* Non-tmp buffers must be freed. These are mostly wrappers around
146  * malloc, etc, but are used so the caller can change the memory
147  * allocators in a future version of the library */
148 
178 LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size);
179 
216 LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size);
217 
225 LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf);
226 
227 /* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
228  normally allocated memory, or on buffers created from
229  icalmemory_new_buffer, never with buffers created by
230  icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
231  buffer on the ring, the ring will loose track of it an you will
232  have memory problems. */
233 
272 LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t *buf_size,
273  const char *string);
274 
314 LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch);
315 
340 LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s);
341 
342 #endif /* !ICALMEMORY_H */
void icalmemory_free_ring(void)
Free all memory used in the ring.
Definition: icalmemory.c:233
char * icalmemory_strdup(const char *s)
Create a duplicate of a string.
Definition: icalmemory.c:257
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition: icalmemory.c:293
void * icalmemory_tmp_buffer(size_t size)
Creates a new temporary buffer on the ring and returns it.
Definition: icalmemory.c:211
void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch)
Append a character to a buffer.
Definition: icalmemory.c:336
void * icalmemory_resize_buffer(void *buf, size_t size)
Resizes a buffer created with icalmemory_new_buffer().
Definition: icalmemory.c:281
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:248
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition: icalmemory.c:267
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Append a string to a buffer.
Definition: icalmemory.c:298
void icalmemory_add_tmp_buffer(void *buf)
Add an externally allocated buffer to the ring.
Definition: icalmemory.c:187