[MPlayer-dev-eng] memalign vs av_malloc
Josh
joshf87 at live.com
Mon Jan 28 02:12:46 CET 2013
It seems some memalign() have been replaced with av_malloc before:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2010-April/064350.html
but seemed kind of weird to replace those but not the ones in sub.c
video.c & win32.c
It doesn't appear malloc.h wasn't necessary so that's why I removed it
from those files.
-------------- next part --------------
Index: configure
===================================================================
--- configure (revision 35905)
+++ configure (working copy)
@@ -3616,7 +3616,6 @@
def_memalign='#define HAVE_MEMALIGN 1'
else
def_memalign='#define HAVE_MEMALIGN 0'
- def_map_memalign='#define memalign(a, b) malloc(b)'
darwin || def_memalign_hack='#define CONFIG_MEMALIGN_HACK 1'
fi
echores "$_memalign"
@@ -8621,7 +8620,6 @@
$def_gettimeofday
$def_glob
$def_langinfo
-$def_map_memalign
$def_memalign
$def_nanosleep
$def_posix_select
Index: sub/sub.c
===================================================================
--- sub/sub.c (revision 35905)
+++ sub/sub.c (working copy)
@@ -21,9 +21,6 @@
#include <string.h>
#include "config.h"
-#if HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include "stream/stream.h"
#include "stream/stream_dvdnav.h"
@@ -155,10 +152,10 @@
len = obj->stride*(obj->bbox.y2-obj->bbox.y1);
if (obj->allocated<len) {
obj->allocated = len;
- free(obj->bitmap_buffer);
- free(obj->alpha_buffer);
- obj->bitmap_buffer = memalign(16, len);
- obj->alpha_buffer = memalign(16, len);
+ av_free(obj->bitmap_buffer);
+ av_free(obj->alpha_buffer);
+ obj->bitmap_buffer = av_malloc(len);
+ obj->alpha_buffer = av_malloc(len);
}
memset(obj->bitmap_buffer, sub_bg_color, len);
memset(obj->alpha_buffer, sub_bg_alpha, len);
@@ -1100,8 +1097,8 @@
mp_osd_obj_t* obj=vo_osd_list;
while(obj){
mp_osd_obj_t* next=obj->next;
- free(obj->alpha_buffer);
- free(obj->bitmap_buffer);
+ av_free(obj->alpha_buffer);
+ av_free(obj->bitmap_buffer);
free(obj);
obj=next;
}
Index: libmpdemux/video.c
===================================================================
--- libmpdemux/video.c (revision 35905)
+++ libmpdemux/video.c (working copy)
@@ -21,9 +21,6 @@
#include "config.h"
#include <stdio.h>
-#if HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -130,7 +127,7 @@
}
mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
if(!videobuffer) {
- videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+ videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -225,7 +222,7 @@
}
mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
if(!videobuffer) {
- videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+ videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -290,7 +287,7 @@
mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
// ========= Read & process sequence header & extension ============
if(!videobuffer) {
- videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+ videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
@@ -358,7 +355,7 @@
}
mp_msg(MSGT_DECVIDEO,MSGL_INFO,"found\n");
if(!videobuffer) {
- videobuffer = memalign(8, VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
+ videobuffer = av_malloc(VIDEOBUFFER_SIZE + MP_INPUT_BUFFER_PADDING_SIZE);
if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, MP_INPUT_BUFFER_PADDING_SIZE);
else {
mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
Index: loader/win32.c
===================================================================
--- loader/win32.c (revision 35905)
+++ loader/win32.c (working copy)
@@ -69,9 +69,6 @@
#ifdef HAVE_KSTAT
#include <kstat.h>
#endif
-#if HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#if HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -348,7 +345,7 @@
void* mreq_private(int size, int to_zero, int type)
{
int nsize = size + sizeof(alloc_header);
- alloc_header* header = memalign(16, nsize);
+ alloc_header* header = av_malloc(nsize);
if (!header)
return 0;
if (to_zero)
More information about the MPlayer-dev-eng
mailing list