[vlc-commits] block: simplify block_shm_Alloc()

Rémi Denis-Courmont git at videolan.org
Sun Jul 8 19:48:35 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul  8 20:33:25 2018 +0300| [1350b2483be9108f02eb878c5a5b6b360f6aa291] | committer: Rémi Denis-Courmont

block: simplify block_shm_Alloc()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1350b2483be9108f02eb878c5a5b6b360f6aa291
---

 src/misc/block.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/misc/block.c b/src/misc/block.c
index 28cf608e70..9bb13fea19 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -324,18 +324,10 @@ block_t *block_mmap_Alloc (void *addr, size_t length)
 #ifdef HAVE_SYS_SHM_H
 # include <sys/shm.h>
 
-typedef struct block_shm_t
-{
-    block_t     self;
-    void       *base_addr;
-} block_shm_t;
-
 static void block_shm_Release (block_t *block)
 {
-    block_shm_t *p_sys = (block_shm_t *)block;
-
-    shmdt (p_sys->base_addr);
-    free (p_sys);
+    shmdt(block->p_start);
+    free(block);
 }
 
 static const struct vlc_block_callbacks block_shm_cbs =
@@ -345,15 +337,14 @@ static const struct vlc_block_callbacks block_shm_cbs =
 
 block_t *block_shm_Alloc (void *addr, size_t length)
 {
-    block_shm_t *block = malloc (sizeof (*block));
+    block_t *block = malloc (sizeof (*block));
     if (unlikely(block == NULL))
     {
         shmdt (addr);
         return NULL;
     }
 
-    block->base_addr = addr;
-    return block_Init(&block->self, &block_shm_cbs, (uint8_t *)addr, length);
+    return block_Init(block, &block_shm_cbs, (uint8_t *)addr, length);
 }
 #else
 block_t *block_shm_Alloc (void *addr, size_t length)



More information about the vlc-commits mailing list