From 950da26b981c6bf6444dbbccab71aca79a141ba1 Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Tue, 13 Jan 2004 22:56:59 +0000 Subject: [PATCH] Two "unknown" parameters of _unDName() turn out to be the output string and it length. If possible, use these instead of allocating a new one. Put the code in _unDNameEx() and call that from _unDName(). --- dlls/msvcrt/main.c | 37 ++++++++++++++++++++++--------------- dlls/msvcrt/msvcrt.h | 3 ++- dlls/msvcrt/msvcrt.spec | 4 ++-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/dlls/msvcrt/main.c b/dlls/msvcrt/main.c index d8033e9b186..dffbe110fac 100644 --- a/dlls/msvcrt/main.c +++ b/dlls/msvcrt/main.c @@ -123,30 +123,31 @@ void MSVCRT_I10_OUTPUT(void) } /********************************************************************* - * __unDName (MSVCRT.@) + * __unDNameEx (MSVCRT.@) * * Demangle a C++ identifier. * * PARAMS - * unknown [I] Not yet determined + * OutStr [O] If not NULL, the place to put the demangled string * mangled [I] Mangled name of the function - * unknown2 [I] Not yet determined + * OutStrLen[I] Length of OutStr * memget [I] Function to allocate memory with * memfree [I] Function to free memory with + * unknown [?] Unknown, possibly a call back * flags [I] Flags determining demangled format * * RETURNS * Success: A string pointing to the unmangled name, allocated with memget. * Failure: NULL. */ -char* MSVCRT___unDName(int unknown, const char* mangled, int unknown2, +char* MSVCRT___unDNameEx(char * OutStr, const char* mangled, int OutStrLen, MSVCRT_malloc_func memget, MSVCRT_free_func memfree, - unsigned int flags) + void * unknown, + unsigned short int flags) { - char* ret; - - FIXME("(%d,%s,%d,%p,%p,%x) stub!\n", unknown, mangled, unknown2, memget, memfree, flags); + FIXME("(%p,%s,%d,%p,%p,%p,%x) stub!\n", + OutStr, mangled, OutStrLen, memget, memfree, unknown, flags); /* FIXME: The code in tools/winebuild/msmangle.c is pretty complete and * could be used here. @@ -164,17 +165,23 @@ char* MSVCRT___unDName(int unknown, const char* mangled, int unknown2, * 0x2000 - Unknown, passed by type_info::name() */ /* Duplicate the mangled name; for comparisons it doesn't matter anyway */ - ret = memget(strlen(mangled) + 1); - strcpy(ret, mangled); - return ret; + if( OutStr == NULL) { + OutStrLen = strlen(mangled) + 1; + OutStr = memget( OutStrLen); + } + strncpy( OutStr, mangled, OutStrLen); + return OutStr; } /********************************************************************* - * __unDNameEx (MSVCRT.@) - * Function not really understood but needed to make the DLL work + * __unDName (MSVCRT.@) */ -char* MSVCRT___unDNameEx(void) +char* MSVCRT___unDName(char * OutStr, const char* mangled, int OutStrLen, + MSVCRT_malloc_func memget, + MSVCRT_free_func memfree, + unsigned short int flags) { - return NULL; + return MSVCRT___unDNameEx( OutStr, mangled, OutStrLen, memget, memfree, + NULL, flags); } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 382e126f605..1d97062a3fc 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -75,7 +75,8 @@ void MSVCRT_operator_delete(void*); typedef void* (*MSVCRT_malloc_func)(MSVCRT_size_t); typedef void (*MSVCRT_free_func)(void*); -extern char* MSVCRT___unDName(int,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,unsigned int); +extern char* MSVCRT___unDName(char *,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,unsigned short int); +extern char* MSVCRT___unDNameEx(char *,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,void *,unsigned short int); /* Setup and teardown multi threaded locks */ extern void msvcrt_init_mt_locks(void); diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 631f197b4df..3e81a864866 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -137,8 +137,8 @@ @ cdecl __threadhandle() kernel32.GetCurrentThread @ cdecl __threadid() kernel32.GetCurrentThreadId @ cdecl __toascii(long) MSVCRT___toascii -@ cdecl __unDName(long str ptr ptr long) MSVCRT___unDName -@ cdecl __unDNameEx() MSVCRT___unDNameEx #FIXME +@ cdecl __unDName(ptr str long ptr ptr long) MSVCRT___unDName +@ cdecl __unDNameEx(ptr str long ptr ptr ptr long) MSVCRT___unDNameEx @ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active @ extern __wargv MSVCRT___wargv @ cdecl __wgetmainargs(ptr ptr ptr long ptr)