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