]> git.sesse.net Git - vlc/blobdiff - include/vlc_block.h
Remove useless test (one more time).
[vlc] / include / vlc_block.h
index 1e155ca9524a31ac1dc856c50da9458587a6998e..fda20ce6434cf440ba271a54156dcd921b2a76d4 100644 (file)
@@ -78,6 +78,8 @@ typedef struct block_sys_t block_sys_t;
 #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;
@@ -95,15 +97,8 @@ struct block_t
     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;
 };
 
 /****************************************************************************
@@ -122,9 +117,15 @@ struct block_t
  *      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 )
 {
@@ -147,6 +148,18 @@ static inline void block_Release( 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
  ****************************************************************************