Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3123dd79
Commit
3123dd79
authored
May 18, 2002
by
Fabrice Bellard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proper memory handling functions
Originally committed as revision 520 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
61a4e8ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
utils.c
libavcodec/utils.c
+22
-13
No files found.
libavcodec/utils.c
View file @
3123dd79
...
@@ -16,21 +16,15 @@
...
@@ -16,21 +16,15 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
#include "mpegvideo.h"
#ifdef HAVE_MALLOC_H
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#endif
/* memory alloc */
/* memory alloc */
void
*
av_malloc
z
(
int
size
)
void
*
av_malloc
(
int
size
)
{
{
void
*
ptr
;
void
*
ptr
;
#if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN )
#if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN )
...
@@ -53,6 +47,24 @@ void *av_mallocz(int size)
...
@@ -53,6 +47,24 @@ void *av_mallocz(int size)
return
ptr
;
return
ptr
;
}
}
void
*
av_mallocz
(
int
size
)
{
void
*
ptr
;
ptr
=
av_malloc
(
size
);
if
(
!
ptr
)
return
NULL
;
memset
(
ptr
,
0
,
size
);
return
ptr
;
}
/* NOTE: ptr = NULL is explicetly allowed */
void
av_free
(
void
*
ptr
)
{
/* XXX: this test should not be needed on most libcs */
if
(
ptr
)
free
(
ptr
);
}
/* encoder management */
/* encoder management */
AVCodec
*
first_avcodec
;
AVCodec
*
first_avcodec
;
...
@@ -80,9 +92,7 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
...
@@ -80,9 +92,7 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
}
}
ret
=
avctx
->
codec
->
init
(
avctx
);
ret
=
avctx
->
codec
->
init
(
avctx
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
avctx
->
priv_data
)
av_freep
(
&
avctx
->
priv_data
);
free
(
avctx
->
priv_data
);
avctx
->
priv_data
=
NULL
;
return
ret
;
return
ret
;
}
}
return
0
;
return
0
;
...
@@ -144,8 +154,7 @@ int avcodec_close(AVCodecContext *avctx)
...
@@ -144,8 +154,7 @@ int avcodec_close(AVCodecContext *avctx)
{
{
if
(
avctx
->
codec
->
close
)
if
(
avctx
->
codec
->
close
)
avctx
->
codec
->
close
(
avctx
);
avctx
->
codec
->
close
(
avctx
);
free
(
avctx
->
priv_data
);
av_freep
(
&
avctx
->
priv_data
);
avctx
->
priv_data
=
NULL
;
avctx
->
codec
=
NULL
;
avctx
->
codec
=
NULL
;
return
0
;
return
0
;
}
}
...
...
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