- Timestamp:
- Jun 19, 2015, 8:37:38 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/dll/filldir.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/filldir.c
r1789 r1814 107 107 28 Jun 14 GKY Fix errors identified with CPPCheck 108 108 30 Aug 14 GKY Use saymsg2 for Suggest dialog 109 19 Jun 15 JBS Ticket 514: Double free fix (which also fixes a memory leak) 109 110 110 111 ***********************************************************************/ … … 1858 1859 } 1859 1860 1860 #if 0 // 26 Sep 09 SHL debug dup free complaints 1861 if (!pci->pszFileName) 1862 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); 1863 else { 1864 if (pci->pszFileName != NullStr) 1861 if (pci->pszFileName) { 1862 if (pci->pszFileName != NullStr) { 1865 1863 free(pci->pszFileName); 1866 pci->pszFileName = NULL; // Catch illegal references 1867 } 1868 #else 1869 { 1870 #define HIST_COUNT 50 1871 static struct { 1872 PCNRITEM pci; 1873 PSZ pszFileName; 1874 } history[HIST_COUNT]; 1875 static volatile UINT iHistNdx; 1876 UINT i; 1877 1878 if (!pci->pszFileName) { 1879 // Looks like pci was already freed 1880 // Try to locate original file name in history buffer 1881 for (i = 0; i < HIST_COUNT && pci != history[i].pci; i++) { } // Scan 1882 if (i < HIST_COUNT) { 1883 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was %.260s", 1884 pci, history[i].pszFileName); 1885 } else { 1886 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); 1887 } 1888 } 1889 else { 1890 PSZ psz; 1891 PSZ *ppsz; 1892 // Grab a history slot 1893 // This should work well enoungh to prevent MT/SMP conflicts 1894 for (;;) { 1895 i = iHistNdx; 1896 if (++i >= HIST_COUNT) 1897 i = 0; 1898 if (++iHistNdx >= HIST_COUNT) 1899 iHistNdx = 0; 1900 if (i == iHistNdx) break; 1901 } 1902 ppsz = &history[iHistNdx].pszFileName; 1903 psz = *ppsz; 1904 if (psz) 1905 free(psz); 1906 if (pci->pszFileName && pci->pszFileName != NullStr) 1907 *ppsz = strdup(pci->pszFileName); 1908 else 1909 *ppsz = NULL; 1910 history[iHistNdx].pci = pci; 1911 if (pci->pszFileName != NullStr) 1912 free(pci->pszFileName); 1913 pci->pszFileName = NULL; // Catch illegal references and dup free attempts 1914 } 1915 } 1916 1917 1918 #endif 1919 1864 } 1865 pci->pszFileName = NULL; // Catch illegal references and dup free attempts 1866 } 1867 1868 // 26 Mar 14 JBS Twice on the longname? 1920 1869 // 08 Sep 08 SHL Remove excess logic 1921 1870 if (pci->pszLongName) { … … 1994 1943 { 1995 1944 INT remaining = usCnt; 1996 BOOL bIdlePrioritySet = FALSE;1997 // #define RCI_ITEMS_PER_TIMER_CHECK (10)1998 // 10 seems a very conservative number1999 // USHORT usTimerCheckCountdown = RCI_ITEMS_PER_TIMER_CHECK;2000 1945 PCNRITEM pci; 2001 1946 ITIMER_DESC itdSleep = { 0 }; // 30 May 11 GKY … … 2022 1967 while (pci) { 2023 1968 FreeCnrItemData(pci); 2024 pci = (PCNRITEM)pci->rc.preccNextRecord;2025 if (!pci)2026 break;2027 1969 if (remaining && --remaining == 0) 2028 1970 break; 2029 if (!bIdlePrioritySet /* && --usTimerCheckCountdown == 0 */) { 2030 bIdlePrioritySet = !IdleIfNeeded(&itdSleep, 30); 2031 // usTimerCheckCountdown = RCI_ITEMS_PER_TIMER_CHECK; 1971 pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, (MPARAM)pci, 1972 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1973 if (pci && !IdleIfNeeded(&itdSleep, 30)) { 1974 // Finishing in idle mode 1975 while (pci) { 1976 FreeCnrItemData(pci); 1977 if (remaining && --remaining == 0) 1978 break; 1979 pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, (MPARAM)pci, 1980 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1981 1982 } 1983 priority_normal(); 1984 break; 2032 1985 } 2033 1986 } // while 2034 if (bIdlePrioritySet)2035 priority_normal();2036 2037 1987 DosPostEventSem(CompactSem); 2038 1988 } 2039 1989 } 2040 2041 // DbgMsg(pszSrcFile, __LINE__, "RemoveCnrItems %p %u %s", pci, usCnt, pci->pszFileName);2042 1990 2043 1991 if (remaining != - 1) { … … 2047 1995 } 2048 1996 } 2049 2050 1997 return remaining; 2051 1998 }
Note:
See TracChangeset
for help on using the changeset viewer.
