summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icalmemory.h
Unidiff
Diffstat (limited to 'libical/src/libical/icalmemory.h') (more/less context) (show whitespace changes)
-rw-r--r--libical/src/libical/icalmemory.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/libical/src/libical/icalmemory.h b/libical/src/libical/icalmemory.h
new file mode 100644
index 0000000..f833c6c
--- a/dev/null
+++ b/libical/src/libical/icalmemory.h
@@ -0,0 +1,85 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalmemory.h
4 CREATOR: eric 30 June 1999
5
6
7 $Id$
8 $Locker$
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of either:
12
13 The LGPL as published by the Free Software Foundation, version
14 2.1, available at: http://www.fsf.org/copyleft/lesser.html
15
16 Or:
17
18 The Mozilla Public License Version 1.0. You may obtain a copy of
19 the License at http://www.mozilla.org/MPL/
20
21 The Initial Developer of the Original Code is Eric Busboom
22
23 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
24======================================================================*/
25
26#ifndef ICALMEMORY_H
27#define ICALMEMORY_H
28
29#include <sys/types.h> /* for size_t */
30
31// Eugen C. <eug@thekompany.com>
32#ifdef _WIN32
33#include <stddef.h>
34#endif
35// Eugen C. <eug@thekompany.com>
36
37/* Tmp buffers are managed by ical. References can be returned to the
38 caller, although the caller will not own the memory. */
39
40void* icalmemory_tmp_buffer(size_t size);
41char* icalmemory_tmp_copy(const char* str);
42
43/* Add an externally allocated buffer to the ring. */
44void icalmemory_add_tmp_buffer(void*);
45
46
47/* Free all memory used in the ring */
48void icalmemory_free_ring(void);
49
50/* Non-tmp buffers must be freed. These are mostly wrappers around
51 * malloc, etc, but are used so the caller can change the memory
52 * allocators in a future version of the library */
53
54void* icalmemory_new_buffer(size_t size);
55void* icalmemory_resize_buffer(void* buf, size_t size);
56void icalmemory_free_buffer(void* buf);
57
58/* icalmemory_append_string will copy the string 'string' to the
59 buffer 'buf' starting at position 'pos', reallocing 'buf' if it is
60 too small. 'buf_size' is the size of 'buf' and will be changed if
61 'buf' is reallocated. 'pos' will point to the last byte of the new
62 string in 'buf', usually a '\0' */
63
64/* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
65 normally allocated memory, or on buffers created from
66 icalmemory_new_buffer, never with buffers created by
67 icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
68 buffer on the ring, the ring will loose track of it an you will
69 have memory problems. */
70
71void icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
72 const char* string);
73
74/* icalmemory_append_char is similar, but is appends a character instead of a string */
75void icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
76 char ch);
77
78/* A wrapper around strdup. Partly to trap calls to strdup, partly
79 because in -ansi, gcc on Red Hat claims that strudup is undeclared */
80char* icalmemory_strdup(const char *s);
81
82#endif /* !ICALMEMORY_H */
83
84
85