Author: tfaber
Date: Sat Nov 5 10:08:06 2011
New Revision: 54297
URL:
http://svn.reactos.org/svn/reactos?rev=54297&view=rev
Log:
[CRT]
- Sync heap.c and undname.c with Wine 1.3.32
- Remove incorrect casts. Undo an incorrect warning fix. Fixes hang in msvcrt:cpp test
Modified:
trunk/reactos/lib/sdk/crt/wine/heap.c
trunk/reactos/lib/sdk/crt/wine/undname.c
Modified: trunk/reactos/lib/sdk/crt/wine/heap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/wine/heap.c?re…
==============================================================================
--- trunk/reactos/lib/sdk/crt/wine/heap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/wine/heap.c [iso-8859-1] Sat Nov 5 10:08:06 2011
@@ -35,7 +35,8 @@
((((DWORD_PTR)((char *)ptr + alignment + sizeof(void *) + offset)) & \
~(alignment - 1)) - offset))
-typedef void (*MSVCRT_new_handler_func)(size_t size);
+
+typedef int (CDECL *MSVCRT_new_handler_func)(size_t size);
static MSVCRT_new_handler_func MSVCRT_new_handler;
static int MSVCRT_new_mode;
@@ -50,14 +51,28 @@
*/
void* CDECL MSVCRT_operator_new(size_t size)
{
- void *retval = HeapAlloc(GetProcessHeap(), 0, size);
- TRACE("(%ld) returning %p\n", size, retval);
- if(retval) return retval;
- LOCK_HEAP;
- if(MSVCRT_new_handler)
- (*MSVCRT_new_handler)(size);
- UNLOCK_HEAP;
- return retval;
+ void *retval;
+ int freed;
+
+ do
+ {
+ retval = HeapAlloc(GetProcessHeap(), 0, size);
+ if(retval)
+ {
+ TRACE("(%ld) returning %p\n", size, retval);
+ return retval;
+ }
+
+ LOCK_HEAP;
+ if(MSVCRT_new_handler)
+ freed = (*MSVCRT_new_handler)(size);
+ else
+ freed = 0;
+ UNLOCK_HEAP;
+ } while(freed);
+
+ TRACE("(%ld) out of memory\n", size);
+ return NULL;
}
@@ -148,7 +163,7 @@
*/
void* CDECL _expand(void* mem, size_t size)
{
- return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, (DWORD)size);
+ return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, size);
}
/*********************************************************************
@@ -194,7 +209,7 @@
!HeapValidate( GetProcessHeap(), 0, phe.lpData ))
{
UNLOCK_HEAP;
- __set_errno(GetLastError());
+ __set_errno(GetLastError());
return _HEAPBADNODE;
}
@@ -273,7 +288,7 @@
/*********************************************************************
* calloc (MSVCRT.@)
*/
-void* CDECL calloc(size_t size,size_t count)
+void* CDECL calloc(size_t size, size_t count)
{
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size * count );
}
@@ -303,7 +318,7 @@
void* CDECL realloc(void* ptr, size_t size)
{
if (!ptr) return malloc(size);
- if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, (DWORD)size);
+ if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
free(ptr);
return NULL;
}
Modified: trunk/reactos/lib/sdk/crt/wine/undname.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/wine/undname.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/wine/undname.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/wine/undname.c [iso-8859-1] Sat Nov 5 10:08:06 2011
@@ -103,6 +103,8 @@
const char* right;
};
+static BOOL symbol_demangle(struct parsed_symbol* sym);
+
/******************************************************************
* und_alloc
*
@@ -208,7 +210,7 @@
a->elts[a->num][len] = '\0';
if (++a->num >= a->max) a->max = a->num;
{
- unsigned int i;
+ int i;
char c;
for (i = a->max - 1; i >= 0; i--)
@@ -414,11 +416,17 @@
/******************************************************************
* get_modifier
- * Parses the type modifier. Always returns a static string
- */
-static BOOL get_modifier(char ch, const char** ret)
-{
- switch (ch)
+ * Parses the type modifier. Always returns static strings.
+ */
+static BOOL get_modifier(struct parsed_symbol *sym, const char **ret, const char
**ptr_modif)
+{
+ *ptr_modif = NULL;
+ if (*sym->current == 'E')
+ {
+ *ptr_modif = "__ptr64";
+ sym->current++;
+ }
+ switch (*sym->current++)
{
case 'A': *ret = NULL; break;
case 'B': *ret = "const"; break;
@@ -434,20 +442,27 @@
{
const char* modifier;
const char* str_modif;
+ const char *ptr_modif = "";
+
+ if (*sym->current == 'E')
+ {
+ ptr_modif = " __ptr64";
+ sym->current++;
+ }
switch (modif)
{
- case 'A': str_modif = " &"; break;
- case 'B': str_modif = " & volatile"; break;
- case 'P': str_modif = " *"; break;
- case 'Q': str_modif = " * const"; break;
- case 'R': str_modif = " * volatile"; break;
- case 'S': str_modif = " * const volatile"; break;
+ case 'A': str_modif = str_printf(sym, " &%s", ptr_modif);
break;
+ case 'B': str_modif = str_printf(sym, " &%s volatile",
ptr_modif); break;
+ case 'P': str_modif = str_printf(sym, " *%s", ptr_modif); break;
+ case 'Q': str_modif = str_printf(sym, " *%s const", ptr_modif);
break;
+ case 'R': str_modif = str_printf(sym, " *%s volatile", ptr_modif);
break;
+ case 'S': str_modif = str_printf(sym, " *%s const volatile",
ptr_modif); break;
case '?': str_modif = ""; break;
default: return FALSE;
}
- if (get_modifier(*sym->current++, &modifier))
+ if (get_modifier(sym, &modifier, &ptr_modif))
{
unsigned mark = sym->stack.num;
struct datatype_t sub_ct;
@@ -582,12 +597,31 @@
name = str_array_get_ref(&sym->names, *sym->current++ -
'0');
break;
case '?':
- if (*++sym->current == '$')
+ switch (*++sym->current)
{
+ case '$':
sym->current++;
if ((name = get_template_name(sym)) &&
!str_array_push(sym, name, -1, &sym->names))
return FALSE;
+ break;
+ case '?':
+ {
+ struct array stack = sym->stack;
+ unsigned int start = sym->names.start;
+ unsigned int num = sym->names.num;
+
+ str_array_init( &sym->stack );
+ if (symbol_demangle( sym )) name = str_printf( sym,
"`%s'", sym->result );
+ sym->names.start = start;
+ sym->names.num = num;
+ sym->stack = stack;
+ }
+ break;
+ default:
+ if (!(name = get_number( sym ))) return FALSE;
+ name = str_printf( sym, "`%s'", name );
+ break;
}
break;
default:
@@ -922,10 +956,10 @@
case '$':
if (*sym->current == 'C')
{
- const char* ptr;
+ const char *ptr, *ptr_modif;
sym->current++;
- if (!get_modifier(*sym->current++, &ptr)) goto done;
+ if (!get_modifier(sym, &ptr, &ptr_modif)) goto done;
if (!demangle_datatype(sym, ct, pmt_ref, in_args)) goto done;
ct->left = str_printf(sym, "%s %s", ct->left, ptr);
}
@@ -958,6 +992,7 @@
const char* access = NULL;
const char* member_type = NULL;
const char* modifier = NULL;
+ const char* ptr_modif;
struct datatype_t ct;
char* name = NULL;
BOOL ret = FALSE;
@@ -1002,14 +1037,16 @@
str_array_init(&pmt);
if (!demangle_datatype(sym, &ct, &pmt, FALSE)) goto done;
- if (!get_modifier(*sym->current++, &modifier)) goto done;
+ if (!get_modifier(sym, &modifier, &ptr_modif)) goto done;
+ if (modifier && ptr_modif) modifier = str_printf(sym, "%s
%s", modifier, ptr_modif);
+ else if (!modifier) modifier = ptr_modif;
sym->stack.num = mark;
}
break;
case '6' : /* compiler generated static */
case '7' : /* compiler generated static */
ct.left = ct.right = NULL;
- if (!get_modifier(*sym->current++, &modifier)) goto done;
+ if (!get_modifier(sym, &modifier, &ptr_modif)) goto done;
if (*sym->current != '@')
{
char* cls = NULL;
@@ -1121,10 +1158,11 @@
{
if (((accmem - 'A') % 8) != 2 && ((accmem - 'A') % 8) !=
3)
{
+ const char *ptr_modif;
/* Implicit 'this' pointer */
/* If there is an implicit this pointer, const modifier follows */
- if (!get_modifier(*sym->current, &modifier)) goto done;
- sym->current++;
+ if (!get_modifier(sym, &modifier, &ptr_modif)) goto done;
+ if (modifier || ptr_modif) modifier = str_printf(sym, "%s %s",
modifier, ptr_modif);
}
}
@@ -1162,12 +1200,11 @@
/* Note: '()' after 'Z' means 'throws', but we don't care
here
* Yet!!! FIXME
*/
- sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s%s%s%s%s",
+ sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s%s%s%s",
access, member_type, ct_ret.left,
(ct_ret.left && !ct_ret.right) ? " " :
NULL,
call_conv, call_conv ? " " : NULL, exported,
- name, args_str, modifier,
- modifier ? " " : NULL, ct_ret.right);
+ name, args_str, modifier, ct_ret.right);
ret = TRUE;
done:
return ret;
@@ -1182,7 +1219,8 @@
const char* name;
const char* args;
- assert(*sym->current++ == '$');
+ assert(*sym->current == '$');
+ sym->current++;
if (!(name = get_literal_string(sym))) return FALSE;
if (!(args = get_args(sym, NULL, FALSE, '<', '>'))) return
FALSE;
sym->result = str_printf(sym, "%s%s", name, args);
@@ -1214,14 +1252,18 @@
/* MS mangled names always begin with '?' */
if (*sym->current != '?') return FALSE;
- str_array_init(&sym->names);
- str_array_init(&sym->stack);
sym->current++;
/* Then function name or operator code */
- if (*sym->current == '?' && sym->current[1] != '$')
+ if (*sym->current == '?' && (sym->current[1] != '$' ||
sym->current[2] == '?'))
{
const char* function_name = NULL;
+
+ if (sym->current[1] == '$')
+ {
+ do_after = 6;
+ sym->current += 2;
+ }
/* C++ operator code (one character, or two if the first is '_') */
switch (*++sym->current)
@@ -1355,6 +1397,17 @@
sym->result = (char*)function_name;
ret = TRUE;
goto done;
+ case 6:
+ {
+ char *args;
+ struct array array_pmt;
+
+ str_array_init(&array_pmt);
+ args = get_args(sym, &array_pmt, FALSE, '<',
'>');
+ if (args != NULL) function_name = str_printf(sym, "%s%s",
function_name, args);
+ sym->names.num = 0;
+ }
+ /* fall through */
default:
if (!str_array_push(sym, function_name, -1, &sym->stack))
return FALSE;
@@ -1400,7 +1453,7 @@
sym->flags &= ~UNDNAME_NO_FUNCTION_RETURNS;
break;
case 5:
- sym->names.start = 1;
+ sym->names.start++;
break;
}
@@ -1461,6 +1514,8 @@
sym.mem_alloc_ptr = memget;
sym.mem_free_ptr = memfree;
sym.current = mangled;
+ str_array_init( &sym.names );
+ str_array_init( &sym.stack );
result = symbol_demangle(&sym) ? sym.result : mangled;
if (buffer && buflen)