$darkmode
Libical API Documentation 4.0 STABLE VERSION Visit the v3.0 documentation
icalmemory.h
Go to the documentation of this file.
1 /*======================================================================
2  FILE: icalmemory.h
3  CREATOR: eric 30 June 1999
4 
5  SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6  SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7 
8  The Initial Developer of the Original Code is Eric Busboom
9 ======================================================================*/
10 
11 #ifndef ICALMEMORY_H
12 #define ICALMEMORY_H
13 
35 #include "libical_ical_export.h"
36 
37 #include <stddef.h>
38 
65 LIBICAL_ICAL_EXPORT void *icalmemory_tmp_buffer(size_t size);
66 
89 LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str);
90 
119 LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf);
120 
138 LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void);
139 
141 typedef void *(*icalmemory_malloc_f)(size_t);
142 typedef void *(*icalmemory_realloc_f)(void *, size_t);
143 typedef void (*icalmemory_free_f)(void *);
145 
162 LIBICAL_ICAL_EXPORT void icalmemory_set_mem_alloc_funcs(icalmemory_malloc_f f_malloc,
163  icalmemory_realloc_f f_realloc,
164  icalmemory_free_f f_free);
165 
176 LIBICAL_ICAL_EXPORT void icalmemory_get_mem_alloc_funcs(icalmemory_malloc_f *f_malloc,
177  icalmemory_realloc_f *f_realloc, icalmemory_free_f *f_free);
178 
211 LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size);
212 
252 LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size);
253 
264 LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf);
265 
266 /* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
267  normally allocated memory, or on buffers created from
268  icalmemory_new_buffer, never with buffers created by
269  icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
270  buffer on the ring, the ring will loose track of it and you will
271  have memory problems. */
272 
311 LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t *buf_size,
312  const char *string);
313 
353 LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch);
354 
381 LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s);
382 
400 LIBICAL_ICAL_EXPORT void icalmemory_append_encoded_string(char **buf, char **pos,
401  size_t *buf_size,
402  const char *string);
416 LIBICAL_ICAL_EXPORT void icalmemory_append_decoded_string(char **buf, char **pos,
417  size_t *buf_size,
418  const char *string);
419 
420 #endif /* !ICALMEMORY_H */
void icalmemory_set_mem_alloc_funcs(icalmemory_malloc_f f_malloc, icalmemory_realloc_f f_realloc, icalmemory_free_f f_free)
Configures the functions to use for memory management.
Definition: icalmemory.c:286
void icalmemory_append_decoded_string(char **buf, char **pos, size_t *buf_size, const char *string)
Definition: icalmemory.c:521
void icalmemory_free_ring(void)
Frees all memory used in the ring.
Definition: icalmemory.c:204
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition: icalmemory.c:242
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition: icalmemory.c:355
void icalmemory_get_mem_alloc_funcs(icalmemory_malloc_f *f_malloc, icalmemory_realloc_f *f_realloc, icalmemory_free_f *f_free)
Returns the functions used for memory management.
Definition: icalmemory.c:295
void icalmemory_append_encoded_string(char **buf, char **pos, size_t *buf_size, const char *string)
Definition: icalmemory.c:478
void * icalmemory_tmp_buffer(size_t size)
Creates a new temporary buffer on the ring and returns it.
Definition: icalmemory.c:182
void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch)
Appends a character to a buffer.
Definition: icalmemory.c:406
void * icalmemory_resize_buffer(void *buf, size_t size)
Resizes a buffer created with icalmemory_new_buffer().
Definition: icalmemory.c:336
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:222
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition: icalmemory.c:315
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
Definition: icalmemory.c:365
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition: icalmemory.c:158