Back to index

lightning-sunbird  0.9+nobinonly
icalmemory.h
Go to the documentation of this file.
00001 /* -*- Mode: C -*- */
00002 /*======================================================================
00003  FILE: icalmemory.h
00004  CREATOR: eric 30 June 1999
00005 
00006 
00007  $Id: icalmemory.h,v 1.4 2002/06/11 12:15:11 acampi Exp $
00008  $Locker:  $
00009 
00010  This program is free software; you can redistribute it and/or modify
00011  it under the terms of either: 
00012 
00013     The LGPL as published by the Free Software Foundation, version
00014     2.1, available at: http://www.fsf.org/copyleft/lesser.html
00015 
00016   Or:
00017 
00018     The Mozilla Public License Version 1.0. You may obtain a copy of
00019     the License at http://www.mozilla.org/MPL/
00020 
00021  The Initial Developer of the Original Code is Eric Busboom
00022 
00023  (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
00024 ======================================================================*/
00025 
00026 #ifndef ICALMEMORY_H
00027 #define ICALMEMORY_H
00028 
00029 #ifndef WIN32
00030 #include <sys/types.h> /* for size_t */
00031 #else
00032 #include <stddef.h>
00033 #endif
00034 
00035 /* Tmp buffers are managed by ical. References can be returned to the
00036    caller, although the caller will not own the memory. */
00037 
00038 void* icalmemory_tmp_buffer(size_t size);
00039 char* icalmemory_tmp_copy(const char* str);
00040 
00042 void  icalmemory_add_tmp_buffer(void*);
00043 
00044 
00046 void icalmemory_free_ring(void);
00047 
00048 /* Non-tmp buffers must be freed. These are mostly wrappers around
00049  * malloc, etc, but are used so the caller can change the memory
00050  * allocators in a future version of the library */
00051 
00052 void* icalmemory_new_buffer(size_t size);
00053 void* icalmemory_resize_buffer(void* buf, size_t size);
00054 void icalmemory_free_buffer(void* buf);
00055 
00063 /* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
00064    normally allocated memory, or on buffers created from
00065    icalmemory_new_buffer, never with buffers created by
00066    icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
00067    buffer on the ring, the ring will loose track of it an you will
00068    have memory problems. */
00069 
00070 void icalmemory_append_string(char** buf, char** pos, size_t* buf_size, 
00071                            const char* string);
00072 
00074 void icalmemory_append_char(char** buf, char** pos, size_t* buf_size, 
00075                            char ch);
00076 
00079 char* icalmemory_strdup(const char *s);
00080 
00081 #endif /* !ICALMEMORY_H */
00082 
00083 
00084