summaryrefslogtreecommitdiffabout
path: root/libical/src
authorzautrix <zautrix>2005-07-04 19:17:50 (UTC)
committer zautrix <zautrix>2005-07-04 19:17:50 (UTC)
commit2710cddd5b0b69efc1c5a7f8516d5b451ff258f1 (patch) (unidiff)
treeabcfa306ccfcdf7aba536cc3f476c0bdbe9ef12b /libical/src
parent4f3238355f67a256f338986ca13322ef23960895 (diff)
downloadkdepimpi-2710cddd5b0b69efc1c5a7f8516d5b451ff258f1.zip
kdepimpi-2710cddd5b0b69efc1c5a7f8516d5b451ff258f1.tar.gz
kdepimpi-2710cddd5b0b69efc1c5a7f8516d5b451ff258f1.tar.bz2
free ring buffer
Diffstat (limited to 'libical/src') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalmemory.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libical/src/libical/icalmemory.c b/libical/src/libical/icalmemory.c
index 18d7ef9..3ed38ad 100644
--- a/libical/src/libical/icalmemory.c
+++ b/libical/src/libical/icalmemory.c
@@ -40,65 +40,65 @@
40 * interfaces simple, I did not want the caller to have to pass in a 40 * interfaces simple, I did not want the caller to have to pass in a
41 * memory buffer, but having libical pass out newly allocated memory 41 * memory buffer, but having libical pass out newly allocated memory
42 * makes it difficult to de-allocate the memory. 42 * makes it difficult to de-allocate the memory.
43 * 43 *
44 * The ring buffer in this scheme makes it possible for libical to pass 44 * The ring buffer in this scheme makes it possible for libical to pass
45 * out references to memory which the caller does not own, and be able 45 * out references to memory which the caller does not own, and be able
46 * to de-allocate the memory later. The ring allows libical to have 46 * to de-allocate the memory later. The ring allows libical to have
47 * several buffers active simultaneously, which is handy when creating 47 * several buffers active simultaneously, which is handy when creating
48 * string representations of components. 48 * string representations of components.
49 */ 49 */
50 50
51#define ICALMEMORY_C 51#define ICALMEMORY_C
52 52
53#ifdef HAVE_CONFIG_H 53#ifdef HAVE_CONFIG_H
54#include "config.h" 54#include "config.h"
55#endif 55#endif
56 56
57#ifdef DMALLOC 57#ifdef DMALLOC
58#include "dmalloc.h" 58#include "dmalloc.h"
59#endif 59#endif
60 60
61#include "icalmemory.h" 61#include "icalmemory.h"
62#include "icalerror.h" 62#include "icalerror.h"
63 63
64#include <stdio.h> /* for printf (debugging) */ 64#include <stdio.h> /* for printf (debugging) */
65#include <stdlib.h> /* for malloc, realloc */ 65#include <stdlib.h> /* for malloc, realloc */
66#include <string.h> /* for memset(), strdup */ 66#include <string.h> /* for memset(), strdup */
67 67
68#ifdef WIN32 68#ifdef WIN32
69#include <windows.h> 69#include <windows.h>
70#endif 70#endif
71 71
72#define BUFFER_RING_SIZE 50 72#define BUFFER_RING_SIZE 100
73#define MIN_BUFFER_SIZE 64 73#define MIN_BUFFER_SIZE 64
74 74
75 75
76/* HACK. Not threadsafe */ 76/* HACK. Not threadsafe */
77 77
78typedef struct { 78typedef struct {
79 int pos; 79 int pos;
80 void *ring[BUFFER_RING_SIZE]; 80 void *ring[BUFFER_RING_SIZE];
81} buffer_ring; 81} buffer_ring;
82 82
83void icalmemory_free_tmp_buffer (void* buf); 83void icalmemory_free_tmp_buffer (void* buf);
84void icalmemory_free_ring_byval(buffer_ring *br); 84void icalmemory_free_ring_byval(buffer_ring *br);
85 85
86static buffer_ring* global_buffer_ring = 0; 86static buffer_ring* global_buffer_ring = 0;
87 87
88#ifdef HAVE_PTHREAD 88#ifdef HAVE_PTHREAD
89#include <pthread.h> 89#include <pthread.h>
90 90
91static pthread_key_t ring_key; 91static pthread_key_t ring_key;
92static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT; 92static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT;
93 93
94static void ring_destroy(void * buf) { 94static void ring_destroy(void * buf) {
95 if (buf) icalmemory_free_ring_byval((buffer_ring *) buf); 95 if (buf) icalmemory_free_ring_byval((buffer_ring *) buf);
96 pthread_setspecific(ring_key, NULL); 96 pthread_setspecific(ring_key, NULL);
97} 97}
98 98
99static void ring_key_alloc(void) { 99static void ring_key_alloc(void) {
100 pthread_key_create(&ring_key, ring_destroy); 100 pthread_key_create(&ring_key, ring_destroy);
101} 101}
102#endif 102#endif
103 103
104 104