|
|
@ -17,6 +17,12 @@ |
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#include "avcodec.h" |
|
|
|
#include "avcodec.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* here we can use OS dependant allocation functions */ |
|
|
|
|
|
|
|
#undef malloc |
|
|
|
|
|
|
|
#undef free |
|
|
|
|
|
|
|
#undef realloc |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_MALLOC_H |
|
|
|
#ifdef HAVE_MALLOC_H |
|
|
|
#include <malloc.h> |
|
|
|
#include <malloc.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -25,13 +31,15 @@ |
|
|
|
memory allocator. You do not need to suppress this file because the |
|
|
|
memory allocator. You do not need to suppress this file because the |
|
|
|
linker will do it automatically */ |
|
|
|
linker will do it automatically */ |
|
|
|
|
|
|
|
|
|
|
|
/* memory alloc */ |
|
|
|
/**
|
|
|
|
|
|
|
|
* Memory allocation of size byte with alignment suitable for all |
|
|
|
|
|
|
|
* memory accesses (including vectors if available on the |
|
|
|
|
|
|
|
* CPU). av_malloc(0) must return a non NULL pointer. |
|
|
|
|
|
|
|
*/ |
|
|
|
void *av_malloc(unsigned int size) |
|
|
|
void *av_malloc(unsigned int size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
void *ptr; |
|
|
|
void *ptr; |
|
|
|
|
|
|
|
|
|
|
|
// if(size==0) return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined (HAVE_MEMALIGN) |
|
|
|
#if defined (HAVE_MEMALIGN) |
|
|
|
ptr = memalign(16,size); |
|
|
|
ptr = memalign(16,size); |
|
|
|
/* Why 64?
|
|
|
|
/* Why 64?
|
|
|
@ -63,23 +71,17 @@ void *av_malloc(unsigned int size) |
|
|
|
#else |
|
|
|
#else |
|
|
|
ptr = malloc(size); |
|
|
|
ptr = malloc(size); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (!ptr) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
//fprintf(stderr, "%X %d\n", (int)ptr, size);
|
|
|
|
|
|
|
|
/* NOTE: this memset should not be present */ |
|
|
|
|
|
|
|
memset(ptr, 0, size); |
|
|
|
|
|
|
|
return ptr; |
|
|
|
return ptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* realloc which does nothing if the block is large enogh |
|
|
|
* av_realloc semantics (same as glibc): if ptr is NULL and size > 0, |
|
|
|
|
|
|
|
* identical to malloc(size). If size is zero, it is identical to |
|
|
|
|
|
|
|
* free(ptr) and NULL is returned.
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void *av_fast_realloc(void *ptr, int *size, int min_size){ |
|
|
|
void *av_realloc(void *ptr, unsigned int size) |
|
|
|
if(min_size < *size) return ptr; |
|
|
|
{ |
|
|
|
|
|
|
|
return realloc(ptr, size); |
|
|
|
*size= min_size + 10*1024; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return realloc(ptr, *size); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* NOTE: ptr = NULL is explicetly allowed */ |
|
|
|
/* NOTE: ptr = NULL is explicetly allowed */ |
|
|
|