#define BLOCK_FLAG_PRIVATE_MASK 0xffff0000
#define BLOCK_FLAG_PRIVATE_SHIFT 16
+typedef void (*block_free_t) (block_t *);
+
struct block_t
{
block_t *p_next;
size_t i_buffer;
uint8_t *p_buffer;
- /* This way the block_Release can be overloaded
- * Don't mess with it now, if you need it the ask on ML
- */
- void (*pf_release) ( block_t * );
-
- /* Following fields are private, user should never touch it */
- /* XXX never touch that OK !!! the first that access that will
- * have Subversion account removed ;) XXX */
- block_sys_t *p_sys;
+ /* Rudimentary support for overloading block (de)allocation. */
+ block_free_t pf_release;
};
/****************************************************************************
* and decrease are supported). Use it as it is optimised.
* - block_Duplicate : create a copy of a block.
****************************************************************************/
-#define block_New( a, b ) __block_New( NULL, b )
-VLC_EXPORT( block_t *, __block_New, ( vlc_object_t *, size_t ) );
-VLC_EXPORT( block_t *, block_Realloc, ( block_t *, ssize_t i_pre, size_t i_body ) );
+VLC_EXPORT( void, block_Init, ( block_t *, void *, size_t ) );
+VLC_EXPORT( block_t *, block_Alloc, ( size_t ) );
+VLC_EXPORT( block_t *, block_Realloc, ( block_t *, ssize_t i_pre, size_t i_body ) );
+
+static inline block_t *block_New( void *dummy, size_t size )
+{
+ (void)dummy;
+ return block_Alloc (size);
+}
static inline block_t *block_Duplicate( block_t *p_block )
{
p_block->pf_release( p_block );
}
+/**
+ * Creates a block from a virtual address memory mapping (mmap).
+ * This is provided by LibVLC so that mmap blocks can safely be deallocated
+ * even after the allocating plugin has been unloaded from memory.
+ *
+ * @param addr base address of the mapping (as returned by mmap)
+ * @param length length (bytes) of the mapping (as passed to mmap)
+ * @return NULL if addr is MAP_FAILED, or an error occurred (in the later
+ * case, munmap(addr, length) is invoked before returning).
+ */
+VLC_EXPORT( block_t *, block_mmap_Alloc, (void *addr, size_t length) );
+
/****************************************************************************
* Chains of blocks functions helper
****************************************************************************