[Mplayer-cvslog] CVS: main/loader ext.c,1.4,1.5 module.c,1.4,1.5 pe_image.c,1.5,1.6 win32.c,1.24,1.25 win32.h,1.4,1.5

Arpi of Ize arpi at mplayer.dev.hu
Sat Nov 3 20:41:48 CET 2001


Update of /cvsroot/mplayer/main/loader
In directory mplayer:/var/tmp.root/cvs-serv15458

Modified Files:
	ext.c module.c pe_image.c win32.c win32.h 
Log Message:
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)

Index: ext.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/ext.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ext.c	4 Oct 2001 02:21:34 -0000	1.4
+++ ext.c	3 Nov 2001 19:40:38 -0000	1.5
@@ -1,5 +1,5 @@
 /********************************************************
- * 
+ *
  *
  *      Stub functions for Wine module
  *
@@ -23,25 +23,37 @@
 #include <wine/heap.h>
 #include "ext.h"
 
+#if 0
+//REMOVE SIMPLIFY
+static void* mymalloc(unsigned int size)
+{
+    printf("malloc %d\n", size);
+    return malloc(size);
+}
+
+#undef malloc
+#define malloc mymalloc
+#endif
+
 int dbg_header_err( const char *dbg_channel, const char *func )
 {
-    return 0; 
+    return 0;
 }
 int dbg_header_warn( const char *dbg_channel, const char *func )
 {
-    return 0; 
+    return 0;
 }
 int dbg_header_fixme( const char *dbg_channel, const char *func )
 {
-    return 0; 
+    return 0;
 }
 int dbg_header_trace( const char *dbg_channel, const char *func )
 {
-    return 0; 
+    return 0;
 }
 int dbg_vprintf( const char *format, va_list args )
 {
-    return 0; 
+    return 0;
 }
 int __vprintf( const char *format, ... )
 {
@@ -51,9 +63,9 @@
     vprintf(format, va);
     va_end(va);
 #endif
-    return 0; 
+    return 0;
 }
-    
+
 HANDLE WINAPI GetProcessHeap(void)
 {
     return 1;
@@ -61,17 +73,22 @@
 
 LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size)
 {
-    if(flags & 0x8)
-	return calloc(size, 1);
-	else
-	return malloc(size);
+    static int i = 5;
+    void* m = (flags & 0x8) ? calloc(size, 1) : malloc(size);
+    //printf("HeapAlloc %p  %d  (%d)\n", m, size, flags);
+    //if (--i == 0)
+    //    abort();
+    return m;
 }
 
 WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags, LPVOID mem)
 {
     if (mem) free(mem);
+    //printf("HeapFree  %p\n", mem);
+    //if (!mem)
+    //    abort();
     return 1;
-}     	
+}
 
 static int last_error;
 
@@ -81,15 +98,15 @@
 }
 
 VOID WINAPI SetLastError(DWORD error)
-{ 
+{
     last_error=error;
-}    
+}
 
 WIN_BOOL WINAPI ReadFile(HANDLE handle, LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
 {
     *result=read(handle, mem, size);
     return *result;
-}    
+}
 INT WINAPI lstrcmpiA(LPCSTR c1, LPCSTR c2)
 {
     return strcasecmp(c1,c2);
@@ -101,7 +118,7 @@
 INT WINAPI lstrlenA(LPCSTR s)
 {
     return strlen(s);
-}   
+}
 INT WINAPI lstrlenW(LPCWSTR s)
 {
     int l;
@@ -152,9 +169,8 @@
     n--;
     }
     return 0;
-}			
-		
-		
+}
+
 WIN_BOOL WINAPI IsBadReadPtr(LPCVOID data, UINT size)
 {
     if(size==0)
@@ -162,7 +178,7 @@
     if(data==NULL)
         return 1;
     return 0;
-}   
+}
 LPSTR HEAP_strdupA(HANDLE heap, DWORD flags, LPCSTR string)
 {
 //    return strdup(string);
@@ -177,10 +193,10 @@
     if(string==0)
 	return 0;
     size=strlen(string);
-    answer=malloc(size+size+2);
+    answer=malloc(2 * (size + 1));
     for(i=0; i<=size; i++)
 	answer[i]=(short)string[i];
-    return answer;	
+    return answer;
 }
 LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string)
 {
@@ -194,7 +210,7 @@
     answer=malloc(size+2);
     for(i=0; i<=size; i++)
 	answer[i]=(char)string[i];
-    return answer;	
+    return answer;
 }
 
 /***********************************************************************
@@ -250,9 +266,9 @@
                      MAP_PRIVATE | MAP_FIXED, fd, offset_low )) != (LPVOID)-1)
     {
 //	    printf("address %08x\n", *(int*)ret);
-//	printf("%x\n", ret);		     
+//	printf("%x\n", ret);
 	    return ret;
-    }		
+    }
 
 //    printf("mmap %d\n", errno);
 
@@ -346,9 +362,9 @@
 	hFile=open("/dev/zero", O_RDWR);
 	if(hFile<0)
 	    return 0;
-    }	    
+    }
     if(!anon)
-    {	
+    {
         len=lseek(hFile, 0, SEEK_END);
 	lseek(hFile, 0, SEEK_SET);
     }
@@ -358,8 +374,8 @@
 	mmap_access |=PROT_READ;
     else
 	mmap_access |=PROT_READ|PROT_WRITE;
-	
-    answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);    
+
+    answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
     if(anon)
         close(hFile);
     if(answer!=(LPVOID)-1)
@@ -368,30 +384,30 @@
 	{
 	    fm=malloc(sizeof(file_mapping));
 	    fm->prev=NULL;
-	}    
+	}
 	else
 	{
 	    fm->next=malloc(sizeof(file_mapping));
 	    fm->next->prev=fm;
 	    fm=fm->next;
 	}
-	fm->next=NULL;    
+	fm->next=NULL;
 	fm->handle=answer;
 	if(name)
 	{
 	    fm->name=malloc(strlen(name)+1);
 	    strcpy(fm->name, name);
-	}    
+	}
 	else
 	    fm->name=NULL;
 	fm->mapping_size=len;
-	
+
 	if(anon)
 	    close(hFile);
 	return (HANDLE)answer;
     }
     return (HANDLE)0;
-}        
+}
 WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
 {
     file_mapping* p;
@@ -411,10 +427,10 @@
 		fm=p->prev;
 	    free(p);
 	    return result;
-	}        
+	}
     }
-    return 0;	
-}    
+    return 0;
+}
 //static int va_size=0;
 struct virt_alloc_s;
 typedef struct virt_alloc_s
@@ -437,7 +453,7 @@
 //    printf("VirtualAlloc(0x%08X, %d)\n", address
     if(address!=0)
     {
-    //check whether we can allow to allocate this 
+    //check whether we can allow to allocate this
         virt_alloc* str=vm;
         while(str)
         {
@@ -445,7 +461,7 @@
 	    {
 		str=str->prev;
 		continue;
-	    }	
+	    }
 	    if((unsigned)address+size<(unsigned)str->address)
 	    {
 		str=str->prev;
@@ -459,16 +475,16 @@
 		    close(fd);
 		    return address; //returning previously reserved memory
 		}
-		return NULL;    
+		return NULL;
 	    }
 	    close(fd);
 	    return NULL;
 	}
-	answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, 
+	answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
 	    MAP_FIXED | MAP_PRIVATE, fd, 0);
-    }	    
+    }
     else
-    answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, 
+    answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
 	 MAP_PRIVATE, fd, 0);
 //    answer=FILE_dommap(-1, address, 0, size, 0, 0,
 //	PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
@@ -494,28 +510,28 @@
     	vm=new_vm;
 	vm->next=0;
 //	if(va_size!=0)
-//	    printf("Multiple VirtualAlloc!\n");	    
+//	    printf("Multiple VirtualAlloc!\n");
 //	printf("answer=0x%08x\n", answer);
         return answer;
-    }	
-}    	
+    }
+}
 WIN_BOOL WINAPI VirtualFree(LPVOID  address, DWORD t1, DWORD t2)//not sure
 {
     virt_alloc* str=vm;
     int answer;
     while(str)
     {
-    if(address!=str->address)
-    {
-	str=str->prev;
-	continue;
-    }	
-    answer=munmap(str->address, str->mapping_size);
-    if(str->next)str->next->prev=str->prev;
-    if(str->prev)str->prev->next=str->next;
-    if(vm==str)vm=0;
-    free(str);
-    return 0;
+	if(address!=str->address)
+	{
+	    str=str->prev;
+	    continue;
+	}
+	answer=munmap(str->address, str->mapping_size);
+	if(str->next)str->next->prev=str->prev;
+	if(str->prev)str->prev->next=str->next;
+	if(vm==str)vm=0;
+	free(str);
+	return 0;
     }
     return -1;
 }
@@ -530,7 +546,7 @@
     if(srclen==-1){srclen=0; while(src[srclen++]);}
 //    for(i=0; i<srclen; i++)
 //	printf("%c", src[i]);
-//    printf("\n");		
+//    printf("\n");
     if(dest==0)
     {
     for(i=0; i<srclen; i++)
@@ -539,10 +555,10 @@
     	if(*src==0)
 	    return i+1;
     }
-	return srclen+1;	    
-    }	
+	return srclen+1;
+    }
     if(used_defch)
-	*used_defch=0;	
+	*used_defch=0;
     for(i=0; i<min(srclen, destlen); i++)
     {
 	*dest=(char)*src;
@@ -550,7 +566,7 @@
 	src++;
 	if(*src==0)
 	    return i+1;
-    }	    
+    }
     return min(srclen, destlen);
 }
 INT WINAPI MultiByteToWideChar(UINT codepage,DWORD flags, LPCSTR src, INT srclen,
@@ -572,5 +588,5 @@
 	if(strcmp(p->name, name)==0)
 	    return (HANDLE)p->handle;
     }
-    return 0;	
+    return 0;
 }

Index: module.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/module.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- module.c	4 Oct 2001 02:21:34 -0000	1.4
+++ module.c	3 Nov 2001 19:40:38 -0000	1.5
@@ -52,6 +52,10 @@
 #include <wine/elfdll.h>
 #endif
 #include "win32.h"
+//#include "driver.h"
+
+//#undef TRACE
+//#define TRACE printf
 
 struct modref_list_t;
 
@@ -60,13 +64,12 @@
     WINE_MODREF* wm;
     struct modref_list_t *next;
     struct modref_list_t *prev;
-}
-modref_list;
+} modref_list;
 
 //WINE_MODREF *local_wm=NULL;
 modref_list* local_wm=NULL;
 
-//HANDLE SegptrHeap;  // unused?
+HANDLE SegptrHeap;
 
 WINE_MODREF *MODULE_FindModule(LPCSTR m)
 {
@@ -113,6 +116,7 @@
 	    return;
 	}
     }
+
 }
 
 WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
@@ -274,9 +278,17 @@
  */
 void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
 {
-//    WINE_MODREF *wm=local_wm;
+    //    WINE_MODREF *wm=local_wm;
+    modref_list* l = local_wm;
     wm->flags &= ~WINE_MODREF_PROCESS_ATTACHED;
     MODULE_InitDll( wm, DLL_PROCESS_DETACH, lpReserved );
+/*    while (l)
+    {
+	modref_list* f = l;
+	l = l->next;
+	free(f);
+    }
+    local_wm = 0;*/
 }
 
 
@@ -298,11 +310,7 @@
 		SetLastError(ERROR_INVALID_PARAMETER);
 		return 0;
 	}
-
 	printf("Loading DLL: '%s'\n", libname);
-	
-//	if(fs_installed==0)
-//	    install_fs();
 
 	while (wm == 0 && listpath[++i])
 	{
@@ -310,7 +318,7 @@
 	    {
 		if (i == 0)
 		    /* check just original file name */
-		    strncpy(path, libname, 511); 
+		    strncpy(path, libname, 511);
                 else
 		    /* check default user path */
 		    strncpy(path, def_path, 300);
@@ -539,3 +547,27 @@
     }
 }
 
+static int acounter = 0;
+void CodecAlloc(void)
+{
+    acounter++;
+}
+
+void CodecRelease(void)
+{
+    acounter--;
+    if (acounter == 0)
+    {
+	for (;;)
+	{
+	    modref_list* list = local_wm;
+	    if (!local_wm)
+		break;
+	    //printf("CODECRELEASE %p\n", list);
+            MODULE_FreeLibrary(list->wm);
+	    MODULE_RemoveFromList(list->wm);
+            if (local_wm == NULL)
+		my_garbagecollection();
+	}
+    }
+}

Index: pe_image.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/pe_image.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pe_image.c	4 Oct 2001 02:21:34 -0000	1.5
+++ pe_image.c	3 Nov 2001 19:40:38 -0000	1.6
@@ -303,13 +303,11 @@
 
 //		    TRACE("--- Ordinal %s,%d\n", name, ordinal);
 		    
-		    thunk_list->u1.Function=LookupExternal(
-		      name, ordinal);
+		    thunk_list->u1.Function=LookupExternal(name, ordinal);
 		} else {		
 		    pe_name = (PIMAGE_IMPORT_BY_NAME)RVA(import_list->u1.AddressOfData);
 //		    TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint);
-		    thunk_list->u1.Function=LookupExternalByName(
-		      name, pe_name->Name);
+		    thunk_list->u1.Function=LookupExternalByName(name, pe_name->Name);
 		}
 		import_list++;
 		thunk_list++;
@@ -335,8 +333,6 @@
 		thunk_list++;
 	    }
 	}
-
-
     }
     return 0;
 }
@@ -857,6 +853,7 @@
 		return NULL;
 	}
 	close(hFile);
+	//printf("^^^^^^^^^^^^^^^^Alloc VM1  %p\n", wm);
 	return wm;
 }
 
@@ -870,10 +867,14 @@
 {
     TRACE(" unloading %s\n", wm->filename);
 
-    HeapFree( GetProcessHeap(), 0, wm->filename );
-    HeapFree( GetProcessHeap(), 0, wm->short_filename );
+    if (wm->filename)
+	free(wm->filename);
+    if (wm->short_filename)
+	free(wm->short_filename);
+    HeapFree( GetProcessHeap(), 0, wm->deps );
     VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE );
     HeapFree( GetProcessHeap(), 0, wm );
+    //printf("^^^^^^^^^^^^^^^^Free VM1  %p\n", wm);
 }
 
 /*****************************************************************************

Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- win32.c	30 Oct 2001 22:40:40 -0000	1.24
+++ win32.c	3 Nov 2001 19:40:38 -0000	1.25
@@ -2,10 +2,10 @@
 
 	Win32 emulation code. Functions that emulate
 	responses from corresponding Win32 API calls.
-         Since we are not going to be able to load 
+         Since we are not going to be able to load
        virtually any DLL, we can only implement this
       much, adding needed functions with each new codec.
-      
+
       Basic principle of implementation: it's not good
       for DLL to know too much about its environment.
[...1764 lines suppressed...]
-			alclist=pp->prev;
-		free(pp->addr);
-		ppsv = pp;
-		pp=pp->prev;
-		free(ppsv);
-		alccnt--;
-	} 
-   printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree,unfreecnt,alclist,alccnt);
+    int unfree = 0, unfreecnt = 0;
+
+    while (last_alloc)
+    {
+	alloc_header* mem = last_alloc + 1;
+	unfree += my_size(mem);
+        unfreecnt++;
+	my_release(mem);
+    }
+    printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt);
 #endif
 }

Index: win32.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- win32.h	8 Oct 2001 22:26:14 -0000	1.4
+++ win32.h	3 Nov 2001 19:40:38 -0000	1.5
@@ -9,7 +9,6 @@
 
 extern void* my_mreq(int size, int to_zero);
 extern int my_release(void* memory);
-extern int my_size(void* memory);
 extern void* my_realloc(void *memory,int size);
 extern void my_garbagecollection(void);
 
@@ -200,6 +199,7 @@
 extern LONG WINAPI explstrcpynA(char* str1, const char* str2,int len);
 extern LONG WINAPI explstrcatA(char* str1, const char* str2);
 extern LONG WINAPI expInterlockedExchange(long *dest, long l);
+void WINAPI expInitCommonControls(void);
 
 
 extern void* CDECL expmalloc(int size);
@@ -220,16 +220,21 @@
 extern int expmemcmp(void* dest, void* src, int n);
 extern void *expmemcpy(void* dest, void* src, int n) ;
 extern time_t exptime(time_t* t);
+extern int exprand(void);
+extern void expsrand(int seed);
+extern int exp_ftol(float f);
 extern int expsprintf(char* str, const char* format, ...);
+extern double explog10(double x);
+extern double expcos(double x);
+extern double exppow(double x, double y);
 extern int expsscanf(const char* str, const char* format, ...);
 extern void* expfopen(const char* path, const char* mode);
-
+extern int expfprintf(void* stream, const char* format, ...);
+extern int expprintf(const char* format, ...);
+extern void* expwcscpy(WCHAR* dst, const WCHAR* src);
 
 extern void* LookupExternal(const char* library, int ordinal);
 extern void* LookupExternalByName(const char* library, const char* name);
 
-extern int exprand();
-extern int exp_ftol(float f);
-extern void WINAPI expInitCommonControls();
 
 #endif




More information about the MPlayer-cvslog mailing list