Changeset 6644 for trunk/src/comctl32/comctl32undoc.c
- Timestamp:
- Sep 5, 2001, 2:05:03 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/comctl32undoc.c
r6380 r6644 1 /* $Id: comctl32undoc.c,v 1.22 2001-09-05 12:04:57 bird Exp $ */ 1 2 /* 2 3 * Undocumented functions from COMCTL32.DLL … … 98 99 99 100 FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n", 100 101 phDpa, loadProc, pStream, lParam); 101 102 102 103 if (!phDpa || !loadProc || !pStream) 103 104 return E_INVALIDARG; 104 105 105 106 *phDpa = (HDPA)NULL; … … 110 111 errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition); 111 112 if (errCode != S_OK) 112 113 return errCode; 113 114 114 115 errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead); 115 116 if (errCode != S_OK) 116 117 return errCode; 117 118 118 119 FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n", 119 120 streamData.dwSize, streamData.dwData2, streamData.dwItems); 120 121 121 122 if (lParam < sizeof(STREAMDATA) || 122 123 124 123 streamData.dwSize < sizeof(STREAMDATA) || 124 streamData.dwData2 < 1) { 125 errCode = E_FAIL; 125 126 } 126 127 … … 128 129 hDpa = DPA_Create (streamData.dwItems); 129 130 if (!hDpa) 130 131 return E_OUTOFMEMORY; 131 132 132 133 if (!DPA_Grow (hDpa, streamData.dwItems)) 133 134 return E_OUTOFMEMORY; 134 135 135 136 /* load data from the stream into the dpa */ … … 137 138 for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) { 138 139 errCode = (loadProc)(&loadData, pStream, lParam); 139 140 141 142 143 144 145 140 if (errCode != S_OK) { 141 errCode = S_FALSE; 142 break; 143 } 144 145 *ptr = loadData.ptr; 146 ptr++; 146 147 } 147 148 … … 177 178 178 179 FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n", 179 180 hDpa, loadProc, pStream, lParam); 180 181 181 182 return E_FAIL; … … 200 201 BOOL WINAPI 201 202 DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, 202 203 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam) 203 204 { 204 205 INT nCount; … … 208 209 209 210 TRACE("%p %p %08lx %p %p %08lx)\n", 210 211 hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam); 211 212 212 213 if (IsBadWritePtr (hdpa1, sizeof(DPA))) 213 214 return FALSE; 214 215 215 216 if (IsBadWritePtr (hdpa2, sizeof(DPA))) 216 217 return FALSE; 217 218 218 219 if (IsBadCodePtr ((FARPROC)pfnCompare)) 219 220 return FALSE; 220 221 221 222 if (IsBadCodePtr ((FARPROC)pfnMerge)) 222 223 return FALSE; 223 224 224 225 if (dwFlags & DPAM_SORT) { 225 226 227 228 229 230 231 226 TRACE("sorting dpa's!\n"); 227 if (hdpa1->nItemCount > 0) 228 DPA_Sort (hdpa1, pfnCompare, lParam); 229 TRACE ("dpa 1 sorted!\n"); 230 if (hdpa2->nItemCount > 0) 231 DPA_Sort (hdpa2, pfnCompare, lParam); 232 TRACE ("dpa 2 sorted!\n"); 232 233 } 233 234 234 235 if (hdpa2->nItemCount < 1) 235 236 return TRUE; 236 237 237 238 TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n", 238 239 hdpa1->nItemCount, hdpa2->nItemCount); 239 240 240 241 … … 250 251 { 251 252 if (nIndex < 0) break; 252 253 TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 253 nResult = (pfnCompare)(*pWork1, *pWork2, lParam); 254 TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", 255 nResult, nIndex, nCount); 256 257 if (nResult == 0) 258 { 259 PVOID ptr; 260 261 ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam); 262 if (!ptr) 263 return FALSE; 264 265 nCount--; 266 pWork2--; 267 *pWork1 = ptr; 268 nIndex--; 269 pWork1--; 270 } 271 else if (nResult < 0) 272 { 273 if (!dwFlags & 8) 274 { 275 PVOID ptr; 276 277 ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1); 278 279 (pfnMerge)(2, ptr, NULL, lParam); 280 } 281 nIndex--; 282 pWork1--; 283 } 284 else 285 { 286 if (!dwFlags & 4) 287 { 288 PVOID ptr; 289 290 ptr = (pfnMerge)(3, *pWork2, NULL, lParam); 291 if (!ptr) 292 return FALSE; 293 DPA_InsertPtr (hdpa1, nIndex, ptr); 294 } 295 nCount--; 296 pWork2--; 297 } 297 298 298 299 } … … 358 359 359 360 if (lpSrc) 360 361 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize); 361 362 else 362 363 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize); 363 364 364 365 TRACE("-- ret=%p\n", lpDest); … … 458 459 HANDLE WINAPI 459 460 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, 460 461 DWORD dwParam3, DWORD dwParam4); 461 462 462 463 … … 490 491 #if 0 491 492 if (!(hmru->dwParam1 & 1001)) { 492 493 494 493 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ, 494 hmru->lpszMRUString, 495 strlen (hmru->lpszMRUString)); 495 496 } 496 497 … … 506 507 /************************************************************************** 507 508 * AddMRUData [COMCTL32.167] 508 * 509 * 509 510 * Add item to MRU binary list. If item already exists in list then it is 510 511 * simply moved up to the top of the list and not added again. If list is … … 530 531 /************************************************************************** 531 532 * AddMRUStringA [COMCTL32.153] 532 * 533 * 533 534 * Add item to MRU string list. If item already exists in list them it is 534 535 * simply moved up to the top of the list and not added again. If list is … … 572 573 /************************************************************************** 573 574 * FindMRUData [COMCTL32.169] 574 * 575 * 575 576 * Searches binary list for item that matches lpData of length cbData. 576 577 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value … … 590 591 { 591 592 FIXME("(%08x, %p, %ld, %p) empty stub!\n", 592 593 hList, lpData, cbData, lpRegNum); 593 594 594 595 return 0; … … 597 598 /************************************************************************** 598 599 * FindMRUStringA [COMCTL32.155] 599 * 600 * 600 601 * Searches string list for item that matches lpszString. 601 602 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value … … 614 615 { 615 616 FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString), 616 617 lpRegNum); 617 618 618 619 return 0; … … 640 641 641 642 if (lpcml == NULL) 642 643 return 0; 643 644 644 645 if (lpcml->cbSize < sizeof(CREATEMRULIST)) 645 646 return 0; 646 647 647 648 FIXME("(%lu %lu %lx %lx \"%s\" %p)\n", 648 649 649 lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags, 650 (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare); 650 651 651 652 /* dummy pointer creation */ … … 659 660 /************************************************************************** 660 661 * EnumMRUListA [COMCTL32.154] 661 * 662 * 662 663 * Enumerate item in a list 663 664 * … … 673 674 * of list returns -1. 674 675 * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in 675 * the list. 676 * the list. 676 677 */ 677 678 INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, … … 679 680 { 680 681 FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer, 681 682 nBufferSize); 682 683 return 0; 683 684 } … … 702 703 703 704 if (!lpDest && lpSrc) 704 705 return strlen (lpSrc); 705 706 706 707 if (nMaxLen == 0) 707 708 return 0; 708 709 709 710 if (lpSrc == NULL) { 710 711 711 lpDest[0] = '\0'; 712 return 0; 712 713 } 713 714 714 715 len = strlen (lpSrc); 715 716 if (len >= nMaxLen) 716 717 len = nMaxLen - 1; 717 718 718 719 RtlMoveMemory (lpDest, lpSrc, len); … … 737 738 { 738 739 TRACE("(%p %p)\n", lppDest, lpSrc); 739 740 740 741 if (lpSrc) { 741 742 743 744 745 742 LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1); 743 if (!ptr) 744 return FALSE; 745 strcpy (ptr, lpSrc); 746 *lppDest = ptr; 746 747 } 747 748 else { 748 749 750 751 749 if (*lppDest) { 750 COMCTL32_Free (*lppDest); 751 *lppDest = NULL; 752 } 752 753 } 753 754 … … 775 776 776 777 if (!lpDest && lpSrc) 777 778 return strlenW (lpSrc); 778 779 779 780 if (nMaxLen == 0) 780 781 return 0; 781 782 782 783 if (lpSrc == NULL) { 783 784 784 lpDest[0] = L'\0'; 785 return 0; 785 786 } 786 787 787 788 len = strlenW (lpSrc); 788 789 if (len >= nMaxLen) 789 790 len = nMaxLen - 1; 790 791 791 792 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR)); … … 810 811 { 811 812 TRACE("(%p %p)\n", lppDest, lpSrc); 812 813 813 814 if (lpSrc) { 814 815 816 817 818 819 815 INT len = strlenW (lpSrc) + 1; 816 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR)); 817 if (!ptr) 818 return FALSE; 819 strcpyW (ptr, lpSrc); 820 *lppDest = ptr; 820 821 } 821 822 else { 822 823 824 825 823 if (*lppDest) { 824 COMCTL32_Free (*lppDest); 825 *lppDest = NULL; 826 } 826 827 } 827 828 … … 852 853 853 854 if (!lpDest && lpSrc) 854 855 return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL); 855 856 856 857 if (nMaxLen == 0) 857 858 return 0; 858 859 859 860 if (lpSrc == NULL) { 860 861 861 lpDest[0] = '\0'; 862 return 0; 862 863 } 863 864 864 865 len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL); 865 866 if (len >= nMaxLen) 866 867 len = nMaxLen - 1; 867 868 868 869 WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL); … … 897 898 898 899 if (lpSrc) { 899 900 901 902 903 904 905 900 INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0); 901 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR)); 902 903 if (!ptr) 904 return FALSE; 905 MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len); 906 *lppDest = ptr; 906 907 } 907 908 else { 908 909 910 911 909 if (*lppDest) { 910 COMCTL32_Free (*lppDest); 911 *lppDest = NULL; 912 } 912 913 } 913 914 … … 944 945 if (hdsa) 945 946 { 946 947 hdsa->nItemCount = 0; 947 948 hdsa->pData = NULL; 948 949 950 949 hdsa->nMaxCount = 0; 950 hdsa->nItemSize = nSize; 951 hdsa->nGrow = max(1, nGrow); 951 952 } 952 953 … … 972 973 973 974 if (!hdsa) 974 975 return FALSE; 975 976 976 977 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData))) 977 978 return FALSE; 978 979 979 980 return COMCTL32_Free (hdsa); … … 982 983 983 984 /************************************************************************** 984 * DSA_GetItem [COMCTL32.322] 985 * DSA_GetItem [COMCTL32.322] 985 986 * 986 987 * PARAMS … … 1000 1001 1001 1002 TRACE("(%p %d %p)\n", hdsa, nIndex, pDest); 1002 1003 1003 1004 if (!hdsa) 1004 1005 return FALSE; 1005 1006 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) 1006 1007 return FALSE; 1007 1008 1008 1009 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); … … 1014 1015 1015 1016 /************************************************************************** 1016 * DSA_GetItemPtr [COMCTL32.323] 1017 * DSA_GetItemPtr [COMCTL32.323] 1017 1018 * 1018 1019 * Retrieves a pointer to the specified item. … … 1035 1036 1036 1037 if (!hdsa) 1037 1038 return NULL; 1038 1039 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) 1039 1040 return NULL; 1040 1041 1041 1042 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1042 1043 1043 1044 TRACE("-- ret=%p\n", pSrc); 1044 1045 … … 1048 1049 1049 1050 /************************************************************************** 1050 * DSA_SetItem [COMCTL32.325] 1051 * DSA_SetItem [COMCTL32.325] 1051 1052 * 1052 1053 * Sets the contents of an item in the array. … … 1067 1068 INT nSize, nNewItems; 1068 1069 LPVOID pDest, lpTemp; 1069 1070 1070 1071 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 1071 1072 1072 1073 if ((!hdsa) || nIndex < 0) 1073 1074 1074 return FALSE; 1075 1075 1076 if (hdsa->nItemCount <= nIndex) { 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 } 1077 /* within the old array */ 1078 if (hdsa->nMaxCount > nIndex) { 1079 /* within the allocated space, set a new boundary */ 1080 hdsa->nItemCount = nIndex + 1; 1081 } 1082 else { 1083 /* resize the block of memory */ 1084 nNewItems = 1085 hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1); 1086 nSize = hdsa->nItemSize * nNewItems; 1087 1088 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize); 1089 if (!lpTemp) 1090 return FALSE; 1091 1092 hdsa->nMaxCount = nNewItems; 1093 hdsa->nItemCount = nIndex + 1; 1094 hdsa->pData = lpTemp; 1095 } 1095 1096 } 1096 1097 … … 1098 1099 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1099 1100 TRACE("-- move dest=%p src=%p size=%d\n", 1100 1101 pDest, pSrc, hdsa->nItemSize); 1101 1102 memmove (pDest, pSrc, hdsa->nItemSize); 1102 1103 … … 1106 1107 1107 1108 /************************************************************************** 1108 * DSA_InsertItem [COMCTL32.324] 1109 * DSA_InsertItem [COMCTL32.324] 1109 1110 * 1110 1111 * PARAMS … … 1124 1125 LPVOID lpTemp, lpDest; 1125 1126 LPDWORD p; 1126 1127 1127 1128 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 1128 1129 1129 1130 if ((!hdsa) || nIndex < 0) 1130 1131 return -1; 1131 1132 1132 1133 for (i = 0; i < hdsa->nItemSize; i += 4) { 1133 1134 1135 1136 1137 1138 } 1139 1134 p = *(DWORD**)((char *) pSrc + i); 1135 if (IsBadStringPtrA ((char*)p, 256)) 1136 TRACE("-- %d=%p\n", i, (DWORD*)p); 1137 else 1138 TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p)); 1139 } 1140 1140 1141 /* when nIndex >= nItemCount then append */ 1141 1142 if (nIndex >= hdsa->nItemCount) 1142 1143 nIndex = hdsa->nItemCount; 1143 1144 1144 1145 /* do we need to resize ? */ 1145 1146 if (hdsa->nItemCount >= hdsa->nMaxCount) { 1146 1147 1148 1149 1150 1151 1152 1153 1154 hdsa->pData = lpTemp; 1147 nNewItems = hdsa->nMaxCount + hdsa->nGrow; 1148 nSize = hdsa->nItemSize * nNewItems; 1149 1150 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize); 1151 if (!lpTemp) 1152 return -1; 1153 1154 hdsa->nMaxCount = nNewItems; 1155 hdsa->pData = lpTemp; 1155 1156 } 1156 1157 1157 1158 /* do we need to move elements ? */ 1158 1159 if (nIndex < hdsa->nItemCount) { 1159 1160 1161 1162 1163 1164 1160 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1161 lpDest = (char *) lpTemp + hdsa->nItemSize; 1162 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize; 1163 TRACE("-- move dest=%p src=%p size=%d\n", 1164 lpDest, lpTemp, nSize); 1165 memmove (lpDest, lpTemp, nSize); 1165 1166 } 1166 1167 … … 1169 1170 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1170 1171 TRACE("-- move dest=%p src=%p size=%d\n", 1171 1172 lpDest, pSrc, hdsa->nItemSize); 1172 1173 memmove (lpDest, pSrc, hdsa->nItemSize); 1173 1174 … … 1177 1178 1178 1179 /************************************************************************** 1179 * DSA_DeleteItem [COMCTL32.326] 1180 * DSA_DeleteItem [COMCTL32.326] 1180 1181 * 1181 1182 * PARAMS … … 1193 1194 LPVOID lpDest,lpSrc; 1194 1195 INT nSize; 1195 1196 1196 1197 TRACE("(%p %d)\n", hdsa, nIndex); 1197 1198 1198 1199 if (!hdsa) 1199 1200 return -1; 1200 1201 if (nIndex < 0 || nIndex >= hdsa->nItemCount) 1201 1202 return -1; 1202 1203 1203 1204 /* do we need to move ? */ 1204 1205 if (nIndex < hdsa->nItemCount - 1) { 1205 1206 1207 1208 1209 1210 1211 } 1212 1206 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1207 lpSrc = (char *) lpDest + hdsa->nItemSize; 1208 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1); 1209 TRACE("-- move dest=%p src=%p size=%d\n", 1210 lpDest, lpSrc, nSize); 1211 memmove (lpDest, lpSrc, nSize); 1212 } 1213 1213 1214 hdsa->nItemCount--; 1214 1215 1215 1216 /* free memory ? */ 1216 1217 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) { 1217 1218 1219 1220 1221 1222 1223 1224 1218 nSize = hdsa->nItemSize * hdsa->nItemCount; 1219 1220 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize); 1221 if (!lpDest) 1222 return -1; 1223 1224 hdsa->nMaxCount = hdsa->nItemCount; 1225 hdsa->pData = lpDest; 1225 1226 } 1226 1227 … … 1247 1248 TRACE("(%p)\n", hdsa); 1248 1249 1249 if (!hdsa) 1250 1250 if (!hdsa) 1251 return FALSE; 1251 1252 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData))) 1252 1253 return FALSE; 1253 1254 1254 1255 hdsa->nItemCount = 0; … … 1285 1286 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA)); 1286 1287 if (hdpa) { 1287 1288 1289 1290 1291 1288 hdpa->nGrow = max(8, nGrow); 1289 hdpa->hHeap = COMCTL32_hHeap; 1290 hdpa->nMaxCount = hdpa->nGrow * 2; 1291 hdpa->ptrs = 1292 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID)); 1292 1293 } 1293 1294 … … 1315 1316 1316 1317 if (!hdpa) 1317 1318 return FALSE; 1318 1319 1319 1320 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) 1320 1321 return FALSE; 1321 1322 1322 1323 return HeapFree (hdpa->hHeap, 0, hdpa); … … 1344 1345 1345 1346 if (!hdpa) 1346 1347 return FALSE; 1347 1348 1348 1349 hdpa->nGrow = max(8, nGrow); … … 1379 1380 1380 1381 if (!hdpa) 1381 1382 return NULL; 1382 1383 1383 1384 TRACE("(%p %p)\n", hdpa, hdpaNew); 1384 1385 1385 1386 if (!hdpaNew) { 1386 1387 1388 1389 1390 1387 /* create a new DPA */ 1388 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1389 sizeof(DPA)); 1390 hdpaTemp->hHeap = hdpa->hHeap; 1391 hdpaTemp->nGrow = hdpa->nGrow; 1391 1392 } 1392 1393 else 1393 1394 hdpaTemp = hdpaNew; 1394 1395 1395 1396 if (hdpaTemp->ptrs) { 1396 1397 1398 1399 1400 1397 /* remove old pointer array */ 1398 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs); 1399 hdpaTemp->ptrs = NULL; 1400 hdpaTemp->nItemCount = 0; 1401 hdpaTemp->nMaxCount = 0; 1401 1402 } 1402 1403 1403 1404 /* create a new pointer array */ 1404 1405 nNewItems = hdpaTemp->nGrow * 1405 1406 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1); 1406 1407 nSize = nNewItems * sizeof(LPVOID); 1407 1408 hdpaTemp->ptrs = 1408 1409 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); 1409 1410 hdpaTemp->nMaxCount = nNewItems; 1410 1411 … … 1412 1413 hdpaTemp->nItemCount = hdpa->nItemCount; 1413 1414 memmove (hdpaTemp->ptrs, hdpa->ptrs, 1414 1415 hdpaTemp->nItemCount * sizeof(LPVOID)); 1415 1416 1416 1417 return hdpaTemp; … … 1438 1439 1439 1440 if (!hdpa) 1440 1441 return NULL; 1441 1442 if (!hdpa->ptrs) { 1442 1443 1443 WARN("no pointer array.\n"); 1444 return NULL; 1444 1445 } 1445 1446 if ((i < 0) || (i >= hdpa->nItemCount)) { 1446 1447 1447 WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount); 1448 return NULL; 1448 1449 } 1449 1450 … … 1474 1475 1475 1476 if (!hdpa->ptrs) 1476 1477 return -1; 1477 1478 1478 1479 for (i = 0; i < hdpa->nItemCount; i++) { 1479 1480 1480 if (hdpa->ptrs[i] == p) 1481 return i; 1481 1482 } 1482 1483 … … 1509 1510 1510 1511 if ((!hdpa) || (i < 0)) 1511 1512 return -1; 1512 1513 1513 1514 if (!hdpa->ptrs) { 1514 1515 1516 1517 1518 1519 1515 hdpa->ptrs = 1516 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1517 2 * hdpa->nGrow * sizeof(LPVOID)); 1518 if (!hdpa->ptrs) 1519 return -1; 1520 hdpa->nMaxCount = hdpa->nGrow * 2; 1520 1521 nIndex = 0; 1521 1522 } 1522 1523 else { 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1524 if (hdpa->nItemCount >= hdpa->nMaxCount) { 1525 TRACE("-- resizing\n"); 1526 nNewItems = hdpa->nMaxCount + hdpa->nGrow; 1527 nSize = nNewItems * sizeof(LPVOID); 1528 1529 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1530 hdpa->ptrs, nSize); 1531 if (!lpTemp) 1532 return -1; 1533 hdpa->nMaxCount = nNewItems; 1534 hdpa->ptrs = lpTemp; 1535 } 1536 1537 if (i >= hdpa->nItemCount) { 1538 nIndex = hdpa->nItemCount; 1539 TRACE("-- appending at %d\n", nIndex); 1540 } 1541 else { 1542 TRACE("-- inserting at %d\n", i); 1543 lpTemp = hdpa->ptrs + i; 1544 lpDest = lpTemp + 1; 1545 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID); 1546 TRACE("-- move dest=%p src=%p size=%x\n", 1547 lpDest, lpTemp, nSize); 1548 memmove (lpDest, lpTemp, nSize); 1549 nIndex = i; 1550 } 1550 1551 } 1551 1552 … … 1577 1578 { 1578 1579 LPVOID *lpTemp; 1579 1580 1580 1581 TRACE("(%p %d %p)\n", hdpa, i, p); 1581 1582 1582 1583 if ((!hdpa) || i < 0) 1583 1584 1584 return FALSE; 1585 1585 1586 if (hdpa->nItemCount <= i) { 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 hdpa->ptrs = lpTemp; 1604 } 1587 /* within the old array */ 1588 if (hdpa->nMaxCount > i) { 1589 /* within the allocated space, set a new boundary */ 1590 hdpa->nItemCount = i+1; 1591 } 1592 else { 1593 /* resize the block of memory */ 1594 INT nNewItems = 1595 hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1); 1596 INT nSize = nNewItems * sizeof(LPVOID); 1597 1598 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1599 hdpa->ptrs, nSize); 1600 if (!lpTemp) 1601 return FALSE; 1602 1603 hdpa->nItemCount = nNewItems; 1604 hdpa->ptrs = lpTemp; 1605 } 1605 1606 } 1606 1607 … … 1631 1632 LPVOID *lpDest, *lpSrc, lpTemp = NULL; 1632 1633 INT nSize; 1633 1634 1634 1635 TRACE("(%p %d)\n", hdpa, i); 1635 1636 1636 1637 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount) 1637 1638 return NULL; 1638 1639 1639 1640 lpTemp = hdpa->ptrs[i]; … … 1641 1642 /* do we need to move ?*/ 1642 1643 if (i < hdpa->nItemCount - 1) { 1643 1644 1645 1646 1647 1648 1649 } 1650 1644 lpDest = hdpa->ptrs + i; 1645 lpSrc = lpDest + 1; 1646 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID); 1647 TRACE("-- move dest=%p src=%p size=%x\n", 1648 lpDest, lpSrc, nSize); 1649 memmove (lpDest, lpSrc, nSize); 1650 } 1651 1651 1652 hdpa->nItemCount --; 1652 1653 1653 1654 /* free memory ?*/ 1654 1655 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) { 1655 1656 1657 1658 1659 1660 1661 1662 1663 hdpa->ptrs = (LPVOID*)lpDest; 1656 INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount); 1657 nSize = nNewItems * sizeof(LPVOID); 1658 lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1659 hdpa->ptrs, nSize); 1660 if (!lpDest) 1661 return NULL; 1662 1663 hdpa->nMaxCount = nNewItems; 1664 hdpa->ptrs = (LPVOID*)lpDest; 1664 1665 } 1665 1666 … … 1686 1687 TRACE("(%p)\n", hdpa); 1687 1688 1688 if (!hdpa) 1689 1689 if (!hdpa) 1690 return FALSE; 1690 1691 1691 1692 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) 1692 1693 return FALSE; 1693 1694 1694 1695 hdpa->nItemCount = 0; 1695 1696 hdpa->nMaxCount = hdpa->nGrow * 2; 1696 1697 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1697 1698 hdpa->nMaxCount * sizeof(LPVOID)); 1698 1699 1699 1700 return TRUE; … … 1719 1720 static VOID 1720 1721 DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, 1721 1722 PFNDPACOMPARE pfnCompare, LPARAM lParam) 1722 1723 { 1723 1724 INT m; … … 1725 1726 1726 1727 TRACE("l=%i r=%i\n", l, r); 1727 1728 1728 1729 if (l==r) /* one element is always sorted */ 1729 1730 return; 1730 1731 if (r<l) /* oops, got it in the wrong order */ 1731 1732 { 1732 1733 DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam); 1733 1734 return; 1734 1735 } 1735 1736 m = (l+r)/2; /* divide by two */ 1736 1737 DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam); … … 1738 1739 1739 1740 /* join the two sides */ 1740 while( (l<=m) && (m<r) ) 1741 while( (l<=m) && (m<r) ) 1741 1742 { 1742 1743 if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0) … … 1772 1773 { 1773 1774 if (!hdpa || !pfnCompare) 1774 1775 return FALSE; 1775 1776 1776 1777 TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam); 1777 1778 1778 1779 if ((hdpa->nItemCount > 1) && (hdpa->ptrs)) 1779 1780 1780 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1, 1781 pfnCompare, lParam); 1781 1782 1782 1783 return TRUE; … … 1809 1810 INT WINAPI 1810 1811 DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, 1811 1812 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) 1812 1813 { 1813 1814 if (!hdpa || !pfnCompare || !pFind) 1814 1815 return -1; 1815 1816 1816 1817 TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n", 1817 1818 hdpa, pFind, nStart, pfnCompare, lParam, uOptions); 1818 1819 1819 1820 if (uOptions & DPAS_SORTED) { 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1821 /* array is sorted --> use binary search */ 1822 INT l, r, x, n; 1823 LPVOID *lpPtr; 1824 1825 TRACE("binary search\n"); 1826 1827 l = (nStart == -1) ? 0 : nStart; 1828 r = hdpa->nItemCount - 1; 1829 lpPtr = hdpa->ptrs; 1830 while (r >= l) { 1831 x = (l + r) / 2; 1832 n = (pfnCompare)(pFind, lpPtr[x], lParam); 1833 if (n < 0) 1834 r = x - 1; 1835 else 1836 l = x + 1; 1837 if (n == 0) { 1838 TRACE("-- ret=%d\n", n); 1839 return n; 1840 } 1841 } 1842 1843 if (uOptions & DPAS_INSERTBEFORE) { 1844 TRACE("-- ret=%d\n", r); 1845 return r; 1846 } 1847 1848 if (uOptions & DPAS_INSERTAFTER) { 1849 TRACE("-- ret=%d\n", l); 1850 return l; 1851 } 1851 1852 } 1852 1853 else { 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1854 /* array is not sorted --> use linear search */ 1855 LPVOID *lpPtr; 1856 INT nIndex; 1857 1858 TRACE("linear search\n"); 1859 1860 nIndex = (nStart == -1)? 0 : nStart; 1861 lpPtr = hdpa->ptrs; 1862 for (; nIndex < hdpa->nItemCount; nIndex++) { 1863 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) { 1864 TRACE("-- ret=%d\n", nIndex); 1865 return nIndex; 1866 } 1867 } 1867 1868 } 1868 1869 … … 1894 1895 1895 1896 if (hHeap) 1896 1897 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA)); 1897 1898 else 1898 1899 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA)); 1899 1900 1900 1901 if (hdpa) { 1901 1902 1903 1904 1905 1906 1902 hdpa->nGrow = min(8, nGrow); 1903 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap; 1904 hdpa->nMaxCount = hdpa->nGrow * 2; 1905 hdpa->ptrs = 1906 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, 1907 hdpa->nMaxCount * sizeof(LPVOID)); 1907 1908 } 1908 1909 … … 1940 1941 1941 1942 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n", 1942 1943 1943 lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr, 1944 lpNotify->dwParam5); 1944 1945 1945 1946 if (!lpNotify->hwndTo) 1946 1947 return 0; 1947 1948 1948 1949 if (lpNotify->hwndFrom == -1) { 1949 1950 1950 lpNmh = lpHdr; 1951 idFrom = lpHdr->idFrom; 1951 1952 } 1952 1953 else { 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1954 if (lpNotify->hwndFrom) { 1955 HWND hwndParent = GetParent (lpNotify->hwndFrom); 1956 if (hwndParent) { 1957 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER); 1958 if (hwndParent) 1959 idFrom = GetDlgCtrlID (lpNotify->hwndFrom); 1960 } 1961 } 1962 1963 lpNmh = (lpHdr) ? lpHdr : &nmhdr; 1964 1965 lpNmh->hwndFrom = lpNotify->hwndFrom; 1966 lpNmh->idFrom = idFrom; 1967 lpNmh->code = uCode; 1967 1968 } 1968 1969 … … 1987 1988 LRESULT WINAPI 1988 1989 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo, 1989 1990 UINT uCode, LPNMHDR lpHdr) 1990 1991 { 1991 1992 NOTIFYDATA notify; 1992 1993 1993 1994 TRACE("(0x%04x 0x%04x %d %p)\n", 1994 1995 hwndFrom, hwndTo, uCode, lpHdr); 1995 1996 1996 1997 notify.hwndFrom = hwndFrom; … … 2020 2021 LRESULT WINAPI 2021 2022 COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, 2022 2023 LPNMHDR lpHdr, DWORD dwParam5) 2023 2024 { 2024 2025 NOTIFYDATA notify; … … 2026 2027 2027 2028 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n", 2028 2029 hwndFrom, hwndTo, uCode, lpHdr, dwParam5); 2029 2030 2030 2031 hwndNotify = hwndTo; 2031 2032 if (!hwndTo) { 2032 2033 2034 2035 2036 2033 if (IsWindow (hwndFrom)) { 2034 hwndNotify = GetParent (hwndFrom); 2035 if (!hwndNotify) 2036 return 0; 2037 } 2037 2038 } 2038 2039 … … 2069 2070 2070 2071 if (*lpStr2 == 0) 2071 2072 return ((LPSTR)lpStr1); 2072 2073 len1 = 0; 2073 2074 while (lpStr1[len1] != 0) ++len1; … … 2075 2076 while (lpStr2[len2] != 0) ++len2; 2076 2077 if (len2 == 0) 2077 2078 return ((LPSTR)(lpStr1 + len1)); 2078 2079 first = tolower (*lpStr2); 2079 2080 while (len1 >= len2) { 2080 2081 2082 2083 2084 2085 2081 if (tolower(*lpStr1) == first) { 2082 for (i = 1; i < len2; ++i) 2083 if (tolower (lpStr1[i]) != tolower(lpStr2[i])) 2084 break; 2085 if (i >= len2) 2086 return ((LPSTR)lpStr1); 2086 2087 } 2087 2088 ++lpStr1; --len1; 2088 2089 } 2089 2090 return (NULL); … … 2116 2117 * 2117 2118 * Enumerates all items in a dynamic pointer array. 2118 *2119 * PARAMS2120 * hdpa [I] handle to the dynamic pointer array2121 * enumProc [I]2122 * lParam [I]2123 *2124 * RETURNS2125 * none2126 */2127 2128 VOID WINAPI2129 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)2130 {2131 INT i;2132 2133 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);2134 2135 if (!hdpa)2136 return;2137 if (hdpa->nItemCount <= 0)2138 return;2139 2140 for (i = 0; i < hdpa->nItemCount; i++) {2141 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)2142 return;2143 }2144 2145 return;2146 }2147 2148 2149 /**************************************************************************2150 * DPA_DestroyCallback [COMCTL32.386]2151 *2152 * Enumerates all items in a dynamic pointer array and destroys it.2153 2119 * 2154 2120 * PARAMS … … 2158 2124 * 2159 2125 * RETURNS 2126 * none 2127 */ 2128 2129 VOID WINAPI 2130 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam) 2131 { 2132 INT i; 2133 2134 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam); 2135 2136 if (!hdpa) 2137 return; 2138 if (hdpa->nItemCount <= 0) 2139 return; 2140 2141 for (i = 0; i < hdpa->nItemCount; i++) { 2142 if ((enumProc)(hdpa->ptrs[i], lParam) == 0) 2143 return; 2144 } 2145 2146 return; 2147 } 2148 2149 2150 /************************************************************************** 2151 * DPA_DestroyCallback [COMCTL32.386] 2152 * 2153 * Enumerates all items in a dynamic pointer array and destroys it. 2154 * 2155 * PARAMS 2156 * hdpa [I] handle to the dynamic pointer array 2157 * enumProc [I] 2158 * lParam [I] 2159 * 2160 * RETURNS 2160 2161 * Success: TRUE 2161 2162 * Failure: FALSE … … 2195 2196 2196 2197 if (!hdsa) 2197 2198 return; 2198 2199 if (hdsa->nItemCount <= 0) 2199 2200 return; 2200 2201 2201 2202 for (i = 0; i < hdsa->nItemCount; i++) { 2202 2203 2204 2203 LPVOID lpItem = DSA_GetItemPtr (hdsa, i); 2204 if ((enumProc)(lpItem, lParam) == 0) 2205 return; 2205 2206 } 2206 2207 … … 2301 2302 if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue; 2302 2303 lpGotIt = lpStart; 2303 } 2304 } 2304 2305 return (LPSTR)lpGotIt; 2305 2306 } … … 2355 2356 if( strchrW(lpSet, *(WORD*)lpLoop)) 2356 2357 return (INT)(lpLoop-lpStr); 2357 2358 2358 2359 return (INT)(lpLoop-lpStr); 2359 2360 } … … 2399 2400 2400 2401 if (IsWindow (hwnd) == FALSE) 2401 2402 return FALSE; 2402 2403 2403 2404 if (b == 0) 2404 2405 return FALSE; 2405 2406 2406 2407
Note:
See TracChangeset
for help on using the changeset viewer.