Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
37485818
Commit
37485818
authored
Sep 08, 2008
by
Olivier Aubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
embedded snapshot: avoid an unnecessary double malloc
parent
493e0955
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
23 deletions
+22
-23
src/control/mediacontrol_audio_video.c
src/control/mediacontrol_audio_video.c
+7
-6
src/control/mediacontrol_util.c
src/control/mediacontrol_util.c
+15
-17
No files found.
src/control/mediacontrol_audio_video.c
View file @
37485818
...
...
@@ -100,15 +100,16 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
if
(
p_snapshot
)
{
/* Note: p_snapshot->p_data is directly used, not copied. Thus
do not free it here. */
p_pic
=
private_mediacontrol_createRGBPicture
(
p_snapshot
->
i_width
,
p_snapshot
->
i_height
,
VLC_FOURCC
(
'p'
,
'n'
,
'g'
,
' '
),
p_snapshot
->
date
,
p_snapshot
->
p_data
,
p_snapshot
->
i_datasize
);
p_snapshot
->
i_height
,
VLC_FOURCC
(
'p'
,
'n'
,
'g'
,
' '
),
p_snapshot
->
date
,
p_snapshot
->
p_data
,
p_snapshot
->
i_datasize
);
if
(
!
p_pic
)
{
free
(
p_snapshot
->
p_data
);
free
(
p_snapshot
);
RAISE_NULL
(
mediacontrol_InternalException
,
"Out of memory"
);
}
...
...
src/control/mediacontrol_util.c
View file @
37485818
...
...
@@ -176,20 +176,6 @@ private_mediacontrol_position2microsecond( libvlc_media_player_t * p_media_playe
return
0
;
}
mediacontrol_RGBPicture
*
private_mediacontrol_RGBPicture__alloc
(
int
datasize
)
{
mediacontrol_RGBPicture
*
pic
;
pic
=
(
mediacontrol_RGBPicture
*
)
malloc
(
sizeof
(
mediacontrol_RGBPicture
)
);
if
(
!
pic
)
return
NULL
;
pic
->
size
=
datasize
;
pic
->
data
=
(
char
*
)
malloc
(
datasize
*
sizeof
(
char
)
);
return
pic
;
}
void
mediacontrol_RGBPicture__free
(
mediacontrol_RGBPicture
*
pic
)
{
...
...
@@ -245,13 +231,25 @@ mediacontrol_exception_free( mediacontrol_Exception *exception )
free
(
exception
);
}
/**
* Allocates and initializes a mediacontrol_RGBPicture object.
*
* @param i_width: picture width
* @param i_height: picture width
* @param i_chroma: picture chroma
* @param l_date: picture timestamp
* @param p_data: pointer to the data. The data will be directly used, not copied.
* @param i_datasize: data size in bytes
*
* @return the new object, or NULL on error.
*/
mediacontrol_RGBPicture
*
private_mediacontrol_createRGBPicture
(
int
i_width
,
int
i_height
,
long
i_chroma
,
int64_t
l_date
,
char
*
p_data
,
int
i_datasize
)
char
*
p_data
,
int
i_datasize
)
{
mediacontrol_RGBPicture
*
retval
;
retval
=
private_mediacontrol_RGBPicture__alloc
(
i_datasize
);
retval
=
(
mediacontrol_RGBPicture
*
)
malloc
(
sizeof
(
mediacontrol_RGBPicture
)
);
if
(
retval
)
{
retval
->
width
=
i_width
;
...
...
@@ -259,7 +257,7 @@ private_mediacontrol_createRGBPicture( int i_width, int i_height, long i_chroma,
retval
->
type
=
i_chroma
;
retval
->
date
=
l_date
;
retval
->
size
=
i_datasize
;
memcpy
(
retval
->
data
,
p_data
,
i_datasize
)
;
retval
->
data
=
p_data
;
}
return
retval
;
}
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