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