changeset 6473:6c45b8bf9a3e

date: 2002/06/16 09:10:00; author: nickols_k; state: Exp; lines: +17 -13 fixed some DOS-memory leaks patch adopted from mpxp by Tibcu, this fixes vesaout crashes after playing multiple files.
author atmos4
date Fri, 21 Jun 2002 02:20:30 +0000
parents 210db1a84098
children 654b26c941e5
files linux/vbelib.c
diffstat 1 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/linux/vbelib.c	Thu Jun 20 23:13:36 2002 +0000
+++ b/linux/vbelib.c	Fri Jun 21 02:20:30 2002 +0000
@@ -112,12 +112,20 @@
 
 static unsigned hh_int_10_seg;
 static int fd_mem;
+/*
+the list of supported video modes is stored in the reserved portion of
+the SuperVGA information record by some implementations, and it may
+thus be necessary to either copy the mode list or use a different
+buffer for all subsequent VESA calls
+*/
+static void *controller_info;
 int vbeInit( void )
 {
    unsigned short iopl_port;
    size_t i;
    int retval;
    if(!LRMI_init()) return VBE_VM86_FAIL;
+   if(!(controller_info = LRMI_alloc_real(sizeof(struct VbeInfoBlock)))) return VBE_OUT_OF_DOS_MEM;
    /*
     Allow read/write to ALL io ports
    */
@@ -144,6 +152,7 @@
 {
   __set_cursor_type(my_stdout,1);
   close(fd_mem);
+  LRMI_free_real(controller_info);
   return VBE_OK;
 }
 
@@ -216,25 +225,19 @@
 int vbeGetControllerInfo(struct VbeInfoBlock *data)
 {
   struct LRMI_regs r;
-  void *rm_space;
   int retval;
-  if(!(rm_space = LRMI_alloc_real(sizeof(struct VbeInfoBlock)))) return VBE_OUT_OF_DOS_MEM;
-  memcpy(rm_space,data,sizeof(struct VbeInfoBlock));
+  memcpy(controller_info,data,sizeof(struct VbeInfoBlock));
   memset(&r,0,sizeof(struct LRMI_regs));
   r.eax = 0x4f00;
-  r.es  = VirtToPhysSeg(rm_space);
-  r.edi = VirtToPhysOff(rm_space);
-  if(!VBE_LRMI_int(0x10,&r))
-  {
-     LRMI_free_real(rm_space);
-     return VBE_VM86_FAIL;
-  }
+  r.es  = VirtToPhysSeg(controller_info);
+  r.edi = VirtToPhysOff(controller_info);
+  if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL;
   retval = r.eax & 0xffff;
   if(retval == 0x4f)
   {
     FarPtr fpdata;
     retval = VBE_OK;
-    memcpy(data,rm_space,sizeof(struct VbeInfoBlock));
+    memcpy(data,controller_info,sizeof(struct VbeInfoBlock));
     fpdata.seg = (unsigned long)(data->OemStringPtr) >> 16;
     fpdata.off = (unsigned long)(data->OemStringPtr) & 0xffff;
     data->OemStringPtr = PhysToVirt(fpdata);
@@ -325,6 +328,7 @@
     retval = VBE_OK;
     memcpy(data,rm_space,sizeof(struct VesaModeInfoBlock));
   }
+  LRMI_free_real(rm_space);
   return retval;
 }
 
@@ -344,7 +348,7 @@
   r.eax = 0x4f02;
   r.ebx = mode;
   retval = VBE_LRMI_int(0x10,&r);
-  if(rm_space) LRMI_free_real(rm_space);
+  LRMI_free_real(rm_space);
   if(!retval) return VBE_VM86_FAIL;
   retval = r.eax & 0xffff;
   if(retval == 0x4f)
@@ -682,7 +686,7 @@
   memcpy(rm_space,str,r.ecx);
   r.eax = 0x1300;
   retval = VBE_LRMI_int(0x10,&r);
-  if(rm_space) LRMI_free_real(rm_space);
+  LRMI_free_real(rm_space);
   if(!retval) return VBE_VM86_FAIL;
   retval = r.eax & 0xffff;
   if(retval == 0x4f) retval = VBE_OK;