summaryrefslogtreecommitdiffabout
path: root/libical/src
Side-by-side diff
Diffstat (limited to 'libical/src') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalmemory.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libical/src/libical/icalmemory.c b/libical/src/libical/icalmemory.c
index 058ef37..18d7ef9 100644
--- a/libical/src/libical/icalmemory.c
+++ b/libical/src/libical/icalmemory.c
@@ -56,34 +56,34 @@
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#include "icalmemory.h"
#include "icalerror.h"
#include <stdio.h> /* for printf (debugging) */
#include <stdlib.h> /* for malloc, realloc */
#include <string.h> /* for memset(), strdup */
#ifdef WIN32
#include <windows.h>
#endif
-#define BUFFER_RING_SIZE 2500
-#define MIN_BUFFER_SIZE 200
+#define BUFFER_RING_SIZE 50
+#define MIN_BUFFER_SIZE 64
/* HACK. Not threadsafe */
typedef struct {
int pos;
void *ring[BUFFER_RING_SIZE];
} buffer_ring;
void icalmemory_free_tmp_buffer (void* buf);
void icalmemory_free_ring_byval(buffer_ring *br);
static buffer_ring* global_buffer_ring = 0;
#ifdef HAVE_PTHREAD
#include <pthread.h>
@@ -200,34 +200,35 @@ icalmemory_tmp_buffer (size_t size)
/** get rid of this buffer ring */
void icalmemory_free_ring_byval(buffer_ring *br) {
int i;
for(i=0; i<BUFFER_RING_SIZE; i++){
if ( br->ring[i] != 0){
free( br->ring[i]);
}
}
free(br);
}
void icalmemory_free_ring()
{
buffer_ring *br;
br = get_buffer_ring();
-
icalmemory_free_ring_byval(br);
+ if ( global_buffer_ring == br )
+ global_buffer_ring = 0;
}
/** Like strdup, but the buffer is on the ring. */
char*
icalmemory_tmp_copy(const char* str)
{
char* b = icalmemory_tmp_buffer(strlen(str)+1);
strcpy(b,str);
return b;
}