00001 /* $Id: shmalloc.h,v 1.5 2005/02/03 11:02:20 jlaako Exp $ */ 00002 00003 /* 00004 00005 Shared memory allocator. 00006 00007 Copyright (C) 2005-2007 Nokia Corporation. 00008 00009 Contact: Jussi Laako <jussi.laako@nokia.com> 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Lesser General Public 00013 License as published by the Free Software Foundation; either 00014 version 2.1 of the License, or (at your option) any later version. 00015 00016 This library is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public 00022 License along with this library; if not, write to the Free Software 00023 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 */ 00026 00027 00028 #ifndef SHMALLOC_H 00029 #define SHMALLOC_H 00030 00031 00032 #include "sharedmem.h" 00033 00034 00036 #define SHAREDMEM_ALIGN 8 00037 00039 #define SHAREDMEM_BLOCK_INUSE 0x1 00040 00042 #define SHAREDMEM_FLAGS_MASK 0x1 00043 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 00053 typedef struct _sharedmem_block_t 00054 { 00055 size_t size; 00056 long next; 00057 } sharedmem_block_t; 00058 00059 00063 typedef struct _sharedmem_alloc_t 00064 { 00065 sharedmem_t *shminst; 00066 } sharedmem_alloc_t; 00067 00068 00070 #define SHMALLOC_SHAREDMEM(i) ((i)->shminst) 00071 00072 00080 int sharedmem_alloc_create (sharedmem_alloc_t *inst, sharedmem_t *shminst); 00088 long sharedmem_alloc (sharedmem_alloc_t *inst, size_t size); 00099 long sharedmem_realloc (sharedmem_alloc_t *inst, long old_offset, size_t size); 00107 int sharedmem_free (sharedmem_alloc_t *inst, long offset); 00115 void * sharedmem_alloc_get_ptr (sharedmem_alloc_t *inst, long offset); 00123 int sharedmem_alloc_grow (sharedmem_alloc_t *inst, size_t new_size); 00129 void sharedmem_alloc_list_allocs (sharedmem_alloc_t *inst); 00135 void sharedmem_alloc_list_frees (sharedmem_alloc_t *inst); 00136 00137 00138 #ifdef __cplusplus 00139 } 00140 #endif 00141 00142 #endif