Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
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
34
35#include "libical_ical_export.h"
36
37#include <stddef.h>
38
65LIBICAL_ICAL_EXPORT void *icalmemory_tmp_buffer(size_t size);
66
89LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str);
90
119LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf);
120
138LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void);
139
141typedef void *(*icalmemory_malloc_f)(size_t);
142typedef void *(*icalmemory_realloc_f)(void *, size_t);
143typedef void (*icalmemory_free_f)(void *);
145
162LIBICAL_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
176LIBICAL_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
211LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size);
212
252LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size);
253
264LIBICAL_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
311LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t *buf_size,
312 const char *string);
313
353LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch);
354
381LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s);
382
400LIBICAL_ICAL_EXPORT void icalmemory_append_encoded_string(char **buf, char **pos,
401 size_t *buf_size,
402 const char *string);
416LIBICAL_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_free_ring(void)
Frees all memory used in the ring.
Definition icalmemory.c:202
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition icalmemory.c:353
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition icalmemory.c:240
void icalmemory_append_decoded_string(char **buf, char **pos, size_t *buf_size, const char *string)
Definition icalmemory.c:519
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
Definition icalmemory.c:363
void * icalmemory_resize_buffer(void *buf, size_t size)
Resizes a buffer created with icalmemory_new_buffer().
Definition icalmemory.c:334
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition icalmemory.c:313
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:220
void icalmemory_append_encoded_string(char **buf, char **pos, size_t *buf_size, const char *string)
Definition icalmemory.c:476
void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch)
Appends a character to a buffer.
Definition icalmemory.c:404
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:293
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition icalmemory.c:156
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:284
void * icalmemory_tmp_buffer(size_t size)
Creates a new temporary buffer on the ring and returns it.
Definition icalmemory.c:180