Commit 79e47000 authored by Luca Barbato's avatar Luca Barbato

move memory functions from avcodec to avutil

Originally committed as revision 6330 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 10aa27db
...@@ -35,8 +35,8 @@ extern "C" { ...@@ -35,8 +35,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s #define AV_TOSTRING(s) #s
#define LIBAVCODEC_VERSION_INT ((51<<16)+(14<<8)+0) #define LIBAVCODEC_VERSION_INT ((51<<16)+(15<<8)+0)
#define LIBAVCODEC_VERSION 51.14.0 #define LIBAVCODEC_VERSION 51.15.0
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
...@@ -2633,9 +2633,6 @@ extern AVBitStreamFilter noise_bsf; ...@@ -2633,9 +2633,6 @@ extern AVBitStreamFilter noise_bsf;
/* memory */ /* memory */
void *av_mallocz(unsigned int size);
char *av_strdup(const char *s);
void av_freep(void *ptr);
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
/* for static data only */ /* for static data only */
/* call av_free_static to release all staticaly allocated tables */ /* call av_free_static to release all staticaly allocated tables */
......
...@@ -57,29 +57,6 @@ const uint8_t ff_reverse[256]={ ...@@ -57,29 +57,6 @@ const uint8_t ff_reverse[256]={
static int volatile entangled_thread_counter=0; static int volatile entangled_thread_counter=0;
void *av_mallocz(unsigned int size)
{
void *ptr;
ptr = av_malloc(size);
if (!ptr)
return NULL;
memset(ptr, 0, size);
return ptr;
}
char *av_strdup(const char *s)
{
char *ptr;
int len;
len = strlen(s) + 1;
ptr = av_malloc(len);
if (!ptr)
return NULL;
memcpy(ptr, s, len);
return ptr;
}
/** /**
* realloc which does nothing if the block is large enough * realloc which does nothing if the block is large enough
*/ */
...@@ -93,7 +70,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size) ...@@ -93,7 +70,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
return av_realloc(ptr, *size); return av_realloc(ptr, *size);
} }
static unsigned int last_static = 0; static unsigned int last_static = 0;
static unsigned int allocated_static = 0; static unsigned int allocated_static = 0;
static void** array_static = NULL; static void** array_static = NULL;
...@@ -157,16 +133,6 @@ static void do_free(void) ...@@ -157,16 +133,6 @@ static void do_free(void)
av_free_static(); av_free_static();
} }
/**
* Frees memory and sets the pointer to NULL.
* @param arg pointer to the pointer which should be freed
*/
void av_freep(void *arg)
{
void **ptr= (void**)arg;
av_free(*ptr);
*ptr = NULL;
}
/* encoder management */ /* encoder management */
AVCodec *first_avcodec = NULL; AVCodec *first_avcodec = NULL;
......
...@@ -32,8 +32,8 @@ extern "C" { ...@@ -32,8 +32,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s #define AV_TOSTRING(s) #s
#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+0) #define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+1)
#define LIBAVUTIL_VERSION 49.0.0 #define LIBAVUTIL_VERSION 49.0.1
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT #define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
......
...@@ -403,8 +403,13 @@ tend= read_time();\ ...@@ -403,8 +403,13 @@ tend= read_time();\
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
#endif #endif
/* memory */
void *av_malloc(unsigned int size); void *av_malloc(unsigned int size);
void *av_realloc(void *ptr, unsigned int size); void *av_realloc(void *ptr, unsigned int size);
void av_free(void *ptr); void av_free(void *ptr);
void *av_mallocz(unsigned int size);
char *av_strdup(const char *s);
void av_freep(void *ptr);
#endif /* COMMON_H */ #endif /* COMMON_H */
...@@ -135,3 +135,35 @@ void av_free(void *ptr) ...@@ -135,3 +135,35 @@ void av_free(void *ptr)
#endif #endif
} }
/**
* Frees memory and sets the pointer to NULL.
* @param arg pointer to the pointer which should be freed
*/
void av_freep(void *arg)
{
void **ptr= (void**)arg;
av_free(*ptr);
*ptr = NULL;
}
void *av_mallocz(unsigned int size)
{
void *ptr;
ptr = av_malloc(size);
if (ptr)
memset(ptr, 0, size);
return ptr;
}
char *av_strdup(const char *s)
{
char *ptr;
int len;
len = strlen(s) + 1;
ptr = av_malloc(len);
if (ptr)
memcpy(ptr, s, len);
return ptr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment