Logo Search packages:      
Sourcecode: libical version File versions  Download package

icalmemory.c File Reference


Detailed Description

Common memory management routines.

libical often passes strings back to the caller. To make these interfaces simple, I did not want the caller to have to pass in a memory buffer, but having libical pass out newly allocated memory makes it difficult to de-allocate the memory.

The ring buffer in this scheme makes it possible for libical to pass out references to memory which the caller does not own, and be able to de-allocate the memory later. The ring allows libical to have several buffers active simultaneously, which is handy when creating string representations of components.

Definition in file icalmemory.c.

#include "icalmemory.h"
#include "icalerror.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Classes

struct  buffer_ring

Defines

#define BUFFER_RING_SIZE   2500
#define ICALMEMORY_C
#define MIN_BUFFER_SIZE   200

Functions

static buffer_ring * buffer_ring_new (void)
static buffer_ring * get_buffer_ring (void)
static buffer_ring * get_buffer_ring_global (void)
void icalmemory_add_tmp_buffer (void *buf)
void icalmemory_append_char (char **buf, char **pos, size_t *buf_size, char ch)
void icalmemory_append_string (char **buf, char **pos, size_t *buf_size, const char *string)
void icalmemory_free_buffer (void *buf)
void icalmemory_free_ring ()
void icalmemory_free_ring_byval (buffer_ring *br)
void icalmemory_free_tmp_buffer (void *buf)
void * icalmemory_new_buffer (size_t size)
void * icalmemory_resize_buffer (void *buf, size_t size)
char * icalmemory_strdup (const char *s)
void * icalmemory_tmp_buffer (size_t size)
char * icalmemory_tmp_copy (const char *str)

Variables

static buffer_ring * global_buffer_ring = 0


Generated by  Doxygen 1.6.0   Back to index