Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
bce10e76
Commit
bce10e76
authored
Jul 22, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add block_shm_Alloc()
parent
a02360f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
include/vlc_block.h
include/vlc_block.h
+1
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/misc/block.c
src/misc/block.c
+49
-0
No files found.
include/vlc_block.h
View file @
bce10e76
...
...
@@ -168,6 +168,7 @@ static inline void block_Release( block_t *p_block )
VLC_API
block_t
*
block_heap_Alloc
(
void
*
,
size_t
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_mmap_Alloc
(
void
*
addr
,
size_t
length
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_shm_Alloc
(
void
*
addr
,
size_t
length
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_File
(
int
fd
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_FilePath
(
const
char
*
)
VLC_USED
VLC_MALLOC
;
...
...
src/libvlccore.sym
View file @
bce10e76
...
...
@@ -32,6 +32,7 @@ block_FilePath
block_heap_Alloc
block_Init
block_mmap_Alloc
block_shm_Alloc
block_Realloc
config_AddIntf
config_ChainCreate
...
...
src/misc/block.c
View file @
bce10e76
...
...
@@ -335,6 +335,55 @@ block_t *block_mmap_Alloc (void *addr, size_t length)
}
#endif
#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
);
}
/**
* Creates a block from a System V shared memory segment (shmget()).
* This is provided by LibVLC so that segments can safely be deallocated
* even after the allocating plugin has been unloaded from memory.
*
* @param addr base address of the segment (as returned by shmat())
* @param length length (bytes) of the segment (as passed to shmget())
* @return NULL if an error occurred (in that case, shmdt(addr) is invoked
* before returning NULL).
*/
block_t
*
block_shm_Alloc
(
void
*
addr
,
size_t
length
)
{
block_shm_t
*
block
=
malloc
(
sizeof
(
*
block
));
if
(
unlikely
(
block
==
NULL
))
{
shmdt
(
addr
);
return
NULL
;
}
block_Init
(
&
block
->
self
,
(
uint8_t
*
)
addr
,
length
);
block
->
self
.
pf_release
=
block_shm_Release
;
block
->
base_addr
=
addr
;
return
&
block
->
self
;
}
#else
block_t
*
block_shm_Alloc
(
void
*
addr
,
size_t
length
)
{
(
void
)
addr
;
(
void
)
length
;
abort
();
}
#endif
#ifdef WIN32
# include <io.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment