Libical API Documentation 3.1
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
7 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
8
9 The Initial Developer of the Original Code is Eric Busboom
10======================================================================*/
11
12#ifndef ICALMEMORY_H
13#define ICALMEMORY_H
14
36#include "libical_ical_export.h"
37
64LIBICAL_ICAL_EXPORT void *icalmemory_tmp_buffer(size_t size);
65
88LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str);
89
118LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf);
119
137LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void);
138
139typedef void *(*icalmemory_malloc_f)(size_t);
140typedef void *(*icalmemory_realloc_f)(void *, size_t);
141typedef void (*icalmemory_free_f)(void *);
142
159LIBICAL_ICAL_EXPORT void icalmemory_set_mem_alloc_funcs(icalmemory_malloc_f f_malloc,
160 icalmemory_realloc_f f_realloc,
161 icalmemory_free_f f_free);
162
173LIBICAL_ICAL_EXPORT void icalmemory_get_mem_alloc_funcs(icalmemory_malloc_f *f_malloc,
174 icalmemory_realloc_f *f_realloc, icalmemory_free_f *f_free);
175
208LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size);
209
249LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size);
250
261LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf);
262
263/* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
264 normally allocated memory, or on buffers created from
265 icalmemory_new_buffer, never with buffers created by
266 icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
267 buffer on the ring, the ring will loose track of it an you will
268 have memory problems. */
269
308LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t *buf_size,
309 const char *string);
310
350LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch);
351
378LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s);
379
380#endif /* !ICALMEMORY_H */
void icalmemory_free_ring(void)
Frees all memory used in the ring.
Definition: icalmemory.c:215
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition: icalmemory.c:359
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition: icalmemory.c:249
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
Definition: icalmemory.c:369
void * icalmemory_resize_buffer(void *buf, size_t size)
Resizes a buffer created with icalmemory_new_buffer().
Definition: icalmemory.c:340
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition: icalmemory.c:319
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:232
void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch)
Appends a character to a buffer.
Definition: icalmemory.c:411
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:300
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition: icalmemory.c:167
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:291
void * icalmemory_tmp_buffer(size_t size)
Creates a new temporary buffer on the ring and returns it.
Definition: icalmemory.c:193