[Mplayer-cvslog] CVS: main/libvo vo_gl2.c,1.43,1.44

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sat May 8 23:40:23 CEST 2004


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv31891

Modified Files:
	vo_gl2.c 
Log Message:
fixed memory leak and removed unnecessary static variable


Index: vo_gl2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl2.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- vo_gl2.c	2 May 2004 14:16:13 -0000	1.43
+++ vo_gl2.c	8 May 2004 21:40:20 -0000	1.44
@@ -59,7 +59,6 @@
 #define MODE_RGB 0
 
 /* local data */
-static unsigned char *ImageDataLocal=NULL;
 static unsigned char *ImageData=NULL;
 
 /* X11 related variables */
@@ -210,10 +209,10 @@
   texgrid = (struct TexSquare *)
     calloc (texnumx * texnumy, sizeof (struct TexSquare));
 
-  line_1 = (unsigned char *) ImageDataLocal;
-  line_2 = (unsigned char *) ImageDataLocal+(image_width*image_bytes);
+  line_1 = (unsigned char *) ImageData;
+  line_2 = (unsigned char *) ImageData+(image_width*image_bytes);
 
-  mem_start = (unsigned char *) ImageDataLocal;
+  mem_start = (unsigned char *) ImageData;
 
   raw_line_len = line_2 - line_1;
 
@@ -810,10 +809,8 @@
 
 static int initGl(uint32_t d_width, uint32_t d_height)
 {
-  ImageDataLocal=malloc(image_width*image_height*image_bytes);
-  memset(ImageDataLocal,128,image_width*image_height*image_bytes);
-
-  ImageData=ImageDataLocal;
+  ImageData=malloc(image_width*image_height*image_bytes);
+  memset(ImageData,128,image_width*image_height*image_bytes);
 
   texture_width=image_width;
   texture_height=image_height;
@@ -849,6 +846,9 @@
   
   drawTextureDisplay ();
 
+  free (ImageData);
+  ImageData = NULL;
+
   mp_msg(MSGT_VO, MSGL_V, "[gl2] Using image_bpp=%d, image_bytes=%d, isBGR=%d, \n\tgl_bitmap_format=%s, gl_bitmap_type=%s, \n\tgl_alignment=%d, rgb_size=%d (%d,%d,%d), a_sz=%d, \n\tgl_internal_format=%s\n",
   	image_bpp, image_bytes, image_mode==MODE_BGR, 
         gl_bitmap_format_s, gl_bitmap_type_s, gl_alignment,
@@ -1100,7 +1100,10 @@
 #endif
 
 static void draw_osd(void)
-{ vo_draw_text(image_width,image_height,draw_alpha_fnc); }
+{
+  if (ImageData)
+    vo_draw_text(image_width,image_height,draw_alpha_fnc);
+}
 
 static void
 flip_page(void)




More information about the MPlayer-cvslog mailing list