Index: /trunk/changelog
===================================================================
--- /trunk/changelog	(revision 7028)
+++ /trunk/changelog	(revision 7029)
@@ -1,3 +1,8 @@
-/* $Id: changelog,v 1.1742 2001-10-11 19:25:20 sandervl Exp $ */
+/* $Id: changelog,v 1.1743 2001-10-12 07:06:39 phaller Exp $ */
+
+ 2001-10-11: Patrick Haller <patrick.haller@innotek.de>
+    - include:  o debugtools.h: memory corruption in debugstr_()
+    - KERNEL32: o (cheap) heap lookup acceleration
+                o better profiler calibration :)
 
  2001-10-11: Sander van Leeuwen <sandervl@xs4all.nl>
Index: /trunk/src/kernel32/heapstring.cpp
===================================================================
--- /trunk/src/kernel32/heapstring.cpp	(revision 7028)
+++ /trunk/src/kernel32/heapstring.cpp	(revision 7029)
@@ -1,3 +1,3 @@
-/* $Id: heapstring.cpp,v 1.43 2001-08-03 10:53:49 sandervl Exp $ */
+/* $Id: heapstring.cpp,v 1.44 2001-10-12 07:05:48 phaller Exp $ */
 
 /*
@@ -53,5 +53,6 @@
  *****************************************************************************/
 
-int WIN32API lstrlenA(LPCSTR arg1)
+ODINFUNCTIONNODBG1(int, lstrlenA,
+                   LPCSTR, arg1)
 {
   dprintf2(("KERNEL32: lstrlenA(%s)\n",
@@ -78,5 +79,6 @@
  *****************************************************************************/
 
-int WIN32API lstrlenW(LPCWSTR arg1)
+ODINFUNCTIONNODBG1(int, lstrlenW,
+                   LPCWSTR, arg1)
 {
   int rc;
@@ -107,5 +109,7 @@
  *****************************************************************************/
 
-LPSTR WIN32API lstrcatA(LPSTR arg1, LPCSTR arg2)
+ODINFUNCTIONNODBG2(LPSTR, lstrcatA,
+                   LPSTR, arg1, 
+                   LPCSTR, arg2)
 {
   dprintf2(("KERNEL32: lstrcat(%s,%s)\n",
@@ -132,5 +136,7 @@
  *****************************************************************************/
 
-LPWSTR WIN32API lstrcatW(LPWSTR arg1, LPCWSTR arg2)
+ODINFUNCTIONNODBG2(LPWSTR, lstrcatW,
+                   LPWSTR, arg1,
+                   LPCWSTR, arg2)
 {
   dprintf2(("KERNEL32: OS2lstrcatW(%08xh,%08xh)\n",
@@ -158,5 +164,7 @@
  *****************************************************************************/
 
-int WIN32API lstrcmpA(LPCSTR arg1, LPCSTR  arg2)
+ODINFUNCTIONNODBG2(int, lstrcmpA,
+                   LPCSTR, arg1,
+                   LPCSTR, arg2)
 {
   dprintf2(("KERNEL32: OS2lstrcmpA(%s,%s)\n",
@@ -185,5 +193,8 @@
  *****************************************************************************/
 
-int WIN32API lstrncmpA(LPCSTR arg1, LPCSTR  arg2, int l)
+ODINFUNCTIONNODBG3(int, lstrncmpA,
+                   LPCSTR, arg1, 
+                   LPCSTR, arg2,
+                   int, l)
 {
   dprintf2(("KERNEL32: OS2lstrncmpA(%s,%s,%d)\n",
@@ -206,5 +217,8 @@
  * Author    : Przemyslaw Dobrowolski
  *****************************************************************************/
-INT WINAPI lstrncmpiA( LPCSTR str1, LPCSTR str2, INT n )
+ODINFUNCTIONNODBG3(INT, lstrncmpiA,
+                   LPCSTR, str1,
+                   LPCSTR, str2,
+                   INT, n )
 {
   INT firstch,lastch;
@@ -227,5 +241,8 @@
 }
 //TODO: Don't know if this is completely correct
-int WIN32API lstrncmpiW(LPCWSTR str1, LPCWSTR str2, int n)
+ODINFUNCTIONNODBG3(int, lstrncmpiW,
+                   LPCWSTR, str1, 
+                   LPCWSTR, str2,
+                   int, n)
 {
   INT firstch,lastch;
@@ -260,5 +277,7 @@
  *****************************************************************************/
 
-int WIN32API lstrcmpW(LPCWSTR arg1, LPCWSTR arg2)
+ODINFUNCTIONNODBG2(int, lstrcmpW,
+                   LPCWSTR, arg1,
+                   LPCWSTR, arg2)
 {
     dprintf2(("KERNEL32: lstrcmpW (%08xh, %08xh)\n",
@@ -287,5 +306,8 @@
  *****************************************************************************/
 
-int WIN32API lstrncmpW(LPCWSTR arg1, LPCWSTR  arg2, int l)
+ODINFUNCTIONNODBG3(int, lstrncmpW,
+                   LPCWSTR, arg1,
+                   LPCWSTR, arg2,
+                   int, l)
 {
   dprintf2(("KERNEL32: OS2lstrncmpW(%08xh,%08xh,%d)\n",
@@ -311,5 +333,7 @@
  *****************************************************************************/
 
-LPSTR WIN32API lstrcpyA(LPSTR dest, LPCSTR src)
+ODINFUNCTIONNODBG2(LPSTR, lstrcpyA,
+                   LPSTR, dest,
+                   LPCSTR, src)
 {
     if ( (src == NULL) || (dest == NULL) ) // stupid parameter checking
@@ -332,5 +356,7 @@
  *****************************************************************************/
 
-LPWSTR WIN32API lstrcpyW(LPWSTR dest, LPCWSTR src)
+ODINFUNCTIONNODBG2(LPWSTR, lstrcpyW,
+                   LPWSTR, dest,
+                   LPCWSTR, src)
 {
     if ( (src == NULL) || (dest == NULL) ) // stupid parameter checking
@@ -355,13 +381,11 @@
  *****************************************************************************/
 
-LPSTR WIN32API lstrcpynA(LPSTR arg1, LPCSTR  arg2, int arg3)
+ODINFUNCTIONNODBG3(LPSTR, lstrcpynA,
+                   LPSTR, arg1,
+                   LPCSTR, arg2,
+                   int, arg3)
 {
   register LPSTR p1 = arg1;
   register LPSTR p2 = (LPSTR)arg2;
-
-  dprintf2(("KERNEL32: OS2lstrcpyA(%08xh, %08xh, %08xh)\n",
-           arg1,
-           arg2,
-           arg3));
 
   if(arg3 == 0) {
@@ -395,11 +419,9 @@
  *****************************************************************************/
 
-LPWSTR WIN32API lstrcpynW(LPWSTR dest, LPCWSTR src, int arg3)
-{
-  dprintf2(("KERNEL32: lstrcpynW(%08xh,%08xh,%08xh)",
-           dest,
-           src,
-           arg3));
-
+ODINFUNCTION3(LPWSTR, lstrcpynW,
+              LPWSTR, dest,
+              LPCWSTR, src,
+              int, arg3)
+{
   if (arg3 == 0)
     return NULL;
@@ -425,5 +447,7 @@
  *****************************************************************************/
 
-int WIN32API lstrcmpiA(LPCSTR arg1, LPCSTR  arg2)
+ODINFUNCTIONNODBG2(int, lstrcmpiA,
+                   LPCSTR, arg1,
+                   LPCSTR, arg2)
 {
   dprintf2(("KERNEL32: lstrcmpiA(%s,%s)\n",
@@ -453,13 +477,14 @@
  *****************************************************************************/
 
-int WIN32API lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
-{
-    dprintf2(("KERNEL32: lstrcmpiW(%08xh,%08xh)", str1, str2));
-
-    if (!str1 || !str2) {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return 0;
-    }
-    return strcmpiW( str1, str2 );
+ODINFUNCTIONNODBG2(int, lstrcmpiW,
+                   LPCWSTR, str1,
+                   LPCWSTR, str2)
+{
+  if (!str1 || !str2) {
+    
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return 0;
+  }
+  return strcmpiW( str1, str2 );
 }
 
@@ -468,7 +493,8 @@
 //because Wine code depends on this behaviour (i.e. comdlg32)
 //*****************************************************************************
-int WIN32API lstrcpynWtoA(LPSTR   astring,
-                          LPCWSTR ustring,
-                          int     length)
+ODINFUNCTIONNODBG3(int, lstrcpynWtoA,
+                   LPSTR,   astring,
+                   LPCWSTR, ustring,
+                   int,     length)
 {
  int ret;
@@ -492,7 +518,8 @@
 //lstrcpynWtoA and lstrcpynAtoW must zero-terminate the string
 //because Wine code depends on this behaviour (i.e. comdlg32)
-int WIN32API lstrcpynAtoW(LPWSTR unicode,
-                          LPCSTR  ascii,
-                          int    asciilen)
+ODINFUNCTIONNODBG3(int,     lstrcpynAtoW,
+                   LPWSTR,  unicode,
+                   LPCSTR,  ascii,
+                   int ,    asciilen)
 {
  int ret;
@@ -528,5 +555,7 @@
  *****************************************************************************/
 
-LPSTR WIN32API lstrcpyWtoA(LPSTR ascii, LPCWSTR unicode)
+ODINFUNCTIONNODBG2(LPSTR, lstrcpyWtoA,
+                   LPSTR, ascii,
+                   LPCWSTR, unicode)
 {
     //@@@PH huh? wuz dat?
@@ -564,5 +593,7 @@
  *****************************************************************************/
 
-LPWSTR WIN32API lstrcpyAtoW(LPWSTR unicode, LPCSTR ascii)
+ODINFUNCTIONNODBG2(LPWSTR, lstrcpyAtoW,
+                   LPWSTR, unicode,
+                   LPCSTR, ascii)
 {
     /* achimha for security, strlen might trap if garbage in */
@@ -600,5 +631,8 @@
  *****************************************************************************/
 
-LPVOID WIN32API HEAP_xalloc( HANDLE heap, DWORD flags, DWORD size )
+ODINFUNCTIONNODBG3(LPVOID, HEAP_xalloc,
+                   HANDLE, heap,
+                   DWORD, flags,
+                   DWORD, size )
 {
   LPVOID p = HeapAlloc( heap, flags, size );
@@ -626,5 +660,9 @@
  *****************************************************************************/
 
-LPVOID WIN32API HEAP_xrealloc( HANDLE heap, DWORD flags, LPVOID lpMem, DWORD size )
+ODINFUNCTIONNODBG4(LPVOID, HEAP_xrealloc,
+                   HANDLE, heap,
+                   DWORD, flags,
+                   LPVOID, lpMem,
+                   DWORD, size )
 {
   LPVOID p = HeapReAlloc( heap, flags, lpMem, size );
@@ -653,5 +691,6 @@
  *****************************************************************************/
 
-LPVOID WIN32API HEAP_malloc(DWORD size )
+ODINFUNCTIONNODBG1(LPVOID, HEAP_malloc,
+                   DWORD, size )
 {
   LPVOID p = HeapAlloc( GetProcessHeap(), 0, size );
@@ -677,5 +716,6 @@
  *****************************************************************************/
 
-DWORD WIN32API HEAP_size(LPVOID lpMem)
+ODINFUNCTIONNODBG1(DWORD, HEAP_size,
+                   LPVOID, lpMem)
 {
   return HeapSize( GetProcessHeap(), 0, lpMem );
@@ -695,5 +735,7 @@
  *****************************************************************************/
 
-LPVOID WIN32API HEAP_realloc(LPVOID lpMem, DWORD size )
+ODINFUNCTIONNODBG2(LPVOID, HEAP_realloc,
+                   LPVOID, lpMem,
+                   DWORD, size )
 {
   LPVOID p = HeapReAlloc( GetProcessHeap(), 0, lpMem, size );
@@ -720,9 +762,7 @@
  *****************************************************************************/
 
-VOID WIN32API HEAP_free(LPVOID lpMem)
-{
-  dprintf2(("KERNEL32: HEAP_free(%08xh)\n",
-           lpMem));
-
+ODINPROCEDURENODBG1(HEAP_free,
+                    LPVOID, lpMem)
+{
   HeapFree( GetProcessHeap(), 0, lpMem);
 }
@@ -741,29 +781,36 @@
  *****************************************************************************/
 
-LPSTR WIN32API HEAP_strdupA( HANDLE heap, DWORD flags, LPCSTR str )
-{
-    LPSTR p = (LPSTR)HEAP_xalloc( heap, flags, lstrlenA(str) + 1 );
-    lstrcpyA( p, str );
-    return p;
-}
-
-
-/*****************************************************************************
- * Name      :
- * Purpose   :
- * Parameters:
- * Variables :
- * Result    :
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Thu, 1999/08/05 20:46]
- *****************************************************************************/
-
-LPWSTR WIN32API HEAP_strdupW( HANDLE heap, DWORD flags, LPCWSTR str )
+ODINFUNCTIONNODBG3(LPSTR, HEAP_strdupA,
+                   HANDLE, heap,
+                   DWORD, flags,
+                   LPCSTR, str )
+{
+  int iLength = lstrlenA(str) + 1;
+  LPSTR p = (LPSTR)HEAP_xalloc( heap, flags, iLength );
+  memcpy( p, str, iLength );
+  return p;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Thu, 1999/08/05 20:46]
+ *****************************************************************************/
+
+ODINFUNCTIONNODBG3(LPWSTR, HEAP_strdupW,
+                   HANDLE, heap,
+                   DWORD, flags,
+                   LPCWSTR, str )
 {
     INT len = lstrlenW(str) + 1;
     LPWSTR p = (LPWSTR)HEAP_xalloc( heap, flags, len * sizeof(WCHAR) );
-    lstrcpyW( p, str );
+    memcpy( p, str, len );
     return p;
 }
@@ -782,5 +829,8 @@
  *****************************************************************************/
 
-LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str )
+ODINFUNCTIONNODBG3(LPWSTR, HEAP_strdupAtoW,
+                   HANDLE, heap,
+                   DWORD, flags,
+                   LPCSTR, str )
 {
     LPWSTR ret;
@@ -809,5 +859,8 @@
  *****************************************************************************/
 
-LPSTR WIN32API HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str )
+ODINFUNCTIONNODBG3(LPSTR, HEAP_strdupWtoA,
+                   HANDLE, heap,
+                   DWORD, flags,
+                   LPCWSTR, str )
 {
     LPSTR ret;
Index: /trunk/src/kernel32/os2heap.cpp
===================================================================
--- /trunk/src/kernel32/os2heap.cpp	(revision 7028)
+++ /trunk/src/kernel32/os2heap.cpp	(revision 7029)
@@ -1,3 +1,3 @@
-/* $Id: os2heap.cpp,v 1.27 2001-10-12 03:48:06 phaller Exp $ */
+/* $Id: os2heap.cpp,v 1.28 2001-10-12 07:05:48 phaller Exp $ */
 
 /*
@@ -50,4 +50,6 @@
 //******************************************************************************
 
+static int fhhm_hit = 0;
+static int fhhm_miss = 0;
 static HANDLE   fhhm_lastHandle = 0;
 static OS2Heap* fhhm_lastHeap   = NULL;
@@ -308,5 +310,10 @@
   if (fhhm_lastHeap)
     if (hHeap == fhhm_lastHandle)
+    {
+      fhhm_hit++;
       return fhhm_lastHeap;
+    }
+  
+  fhhm_miss++;
   
   OS2Heap *curheap = OS2Heap::heap;
