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
140typedef void *(*icalmemory_malloc_f)(size_t);
141typedef void *(*icalmemory_realloc_f)(void *, size_t);
142typedef void (*icalmemory_free_f)(void *);
143
160LIBICAL_ICAL_EXPORT void icalmemory_set_mem_alloc_funcs(icalmemory_malloc_f f_malloc,
161 icalmemory_realloc_f f_realloc,
162 icalmemory_free_f f_free);
163
174LIBICAL_ICAL_EXPORT void icalmemory_get_mem_alloc_funcs(icalmemory_malloc_f *f_malloc,
175 icalmemory_realloc_f *f_realloc, icalmemory_free_f *f_free);
176
209LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size);
210
250LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size);
251
262LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf);
263
264/* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
265 normally allocated memory, or on buffers created from
266 icalmemory_new_buffer, never with buffers created by
267 icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
268 buffer on the ring, the ring will loose track of it and you will
269 have memory problems. */
270
309LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t *buf_size,
310 const char *string);
311
351LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch);
352
379LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s);
380
381LIBICAL_ICAL_EXPORT void icalmemory_append_encoded_string(char **buf, char **pos,
382 size_t *buf_size,
383 const char *string);
384
385LIBICAL_ICAL_EXPORT void icalmemory_append_decoded_string(char **buf, char **pos,
386 size_t *buf_size,
387 const char *string);
388
389#endif /* !ICALMEMORY_H */
void icalmemory_free_ring(void)
Frees all memory used in the ring.
Definition icalmemory.c:197
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition icalmemory.c:348
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition icalmemory.c:235
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
Definition icalmemory.c:358
void * icalmemory_resize_buffer(void *buf, size_t size)
Resizes a buffer created with icalmemory_new_buffer().
Definition icalmemory.c:329
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition icalmemory.c:308
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:215
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:399
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:288
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition icalmemory.c:151
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:279
void * icalmemory_tmp_buffer(size_t size)
Creates a new temporary buffer on the ring and returns it.
Definition icalmemory.c:175