1 /* GStreamer 2 * Copyright (C) <2009> Collabora Ltd 3 * @author: Olivier Crete <olivier.crete@collabora.co.uk 4 * Copyright (C) <2009> Nokia Inc 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 #include <stdlib.h> 26 27 #ifndef __SHMALLOC_H__ 28 #define __SHMALLOC_H__ 29 30 #ifdef SHM_PIPE_USE_GLIB 31 #include <glib.h> 32 33 #define spalloc_new(type) g_slice_new (type) 34 #define spalloc_alloc(size) g_slice_alloc (size) 35 36 #define spalloc_free(type, buf) g_slice_free (type, buf) 37 #define spalloc_free1(size, buf) g_slice_free1 (size, buf) 38 39 #else 40 41 #define spalloc_new(type) malloc (sizeof (type)) 42 #define spalloc_alloc(size) malloc (size) 43 44 #define spalloc_free(type, buf) free (buf) 45 #define spalloc_free1(size, buf) free (buf) 46 47 #endif 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 typedef struct _ShmAllocSpace ShmAllocSpace; 54 typedef struct _ShmAllocBlock ShmAllocBlock; 55 56 ShmAllocSpace *shm_alloc_space_new (size_t size); 57 void shm_alloc_space_free (ShmAllocSpace * self); 58 59 60 ShmAllocBlock *shm_alloc_space_alloc_block (ShmAllocSpace * self, 61 unsigned long size); 62 unsigned long shm_alloc_space_alloc_block_get_offset (ShmAllocBlock *block); 63 64 void shm_alloc_space_block_inc (ShmAllocBlock * block); 65 void shm_alloc_space_block_dec (ShmAllocBlock * block); 66 ShmAllocBlock * shm_alloc_space_block_get (ShmAllocSpace * space, 67 unsigned long offset); 68 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 #endif /* __SHMALLOC_H__ */ 75