Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
24140ae7
Commit
24140ae7
authored
Jun 07, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block_heap_Alloc(): create a block from an existing heap allocation
parent
4b36ca62
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
0 deletions
+45
-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
+43
-0
No files found.
include/vlc_block.h
View file @
24140ae7
...
...
@@ -157,6 +157,7 @@ static inline void block_Release( block_t *p_block )
p_block
->
pf_release
(
p_block
);
}
VLC_EXPORT
(
block_t
*
,
block_heap_Alloc
,
(
void
*
,
void
*
,
size_t
)
LIBVLC_USED
);
VLC_EXPORT
(
block_t
*
,
block_mmap_Alloc
,
(
void
*
addr
,
size_t
length
)
LIBVLC_USED
);
VLC_EXPORT
(
block_t
*
,
block_File
,
(
int
fd
)
LIBVLC_USED
);
...
...
src/libvlccore.sym
View file @
24140ae7
...
...
@@ -45,6 +45,7 @@ block_FifoRelease
block_FifoShow
block_FifoWake
block_File
block_heap_Alloc
block_Init
block_mmap_Alloc
block_Realloc
...
...
src/misc/block.c
View file @
24140ae7
...
...
@@ -194,6 +194,49 @@ block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
return
p_block
;
}
typedef
struct
{
block_t
self
;
void
*
mem
;
}
block_heap_t
;
static
void
block_heap_Release
(
block_t
*
self
)
{
block_heap_t
*
block
=
(
block_heap_t
*
)
self
;
free
(
block
->
mem
);
free
(
block
);
}
/**
* Creates a block from a heap allocation.
* This is provided by LibVLC so that manually heap-allocated blocks can safely
* be deallocated even after the origin plugin has been unloaded from memory.
*
* When block_Release() is called, VLC will free() the specified pointer.
*
* @param ptr base address of the heap allocation (will be free()'d)
* @param addr base address of the useful buffer data
* @param length bytes length of the useful buffer datan
* @return NULL in case of error (ptr free()'d in that case), or a valid
* block_t pointer.
*/
block_t
*
block_heap_Alloc
(
void
*
ptr
,
void
*
addr
,
size_t
length
)
{
block_heap_t
*
block
=
malloc
(
sizeof
(
*
block
));
if
(
block
==
NULL
)
{
free
(
addr
);
return
NULL
;
}
block_Init
(
&
block
->
self
,
(
uint8_t
*
)
addr
,
length
);
block
->
self
.
pf_release
=
block_heap_Release
;
block
->
mem
=
ptr
;
return
&
block
->
self
;
}
#ifdef HAVE_MMAP
# include <sys/mman.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