I'm checking your code. Is there any chance you'd send me source/binary of your test application? I think it would speed up things quite a lot. Thanks!
P.S.
anton@rocketdivision.com. Just in case
Brock wrote:
I'm having a problem diagnosing a crash i am getting when calling StarBurn_UDF_FormatTreeItemAsFile. I've written my own test application based on the DVDVideoTrackAtOnceFromTree.exe sample. The main difference i have is that i create the array of UDF_TREE_ITEMs for the file items on the heap.. so i can allocate the exact number i need. If i just allocate a constant array of UDF_TREE_ITEMs my program works fine but if dynamically allocate it, it crashes. I dont see any problem with my memory management so, im confused. Any help would be appreciated. Here is the code in question and a snip of my debug log file:
pstTreeDirectories and pstTreeFiles are declared as:
UDF_TREE_ITEM stTreeDirectories[4] = {0}; //0 is unused UDF_TREE_ITEM * pstTreeFiles = NULL;
here is the problem function
LONG CDVDMovieExporter::FormatDirectoryTreeItems(PUDF_TREE_ITEM pstTreeDirectories, PUDF_TREE_ITEM & pstTreeFiles)
{
CString sTreeItem;
CStringArray arrSearchItems;
DWORD dwGuid = 0;
HANDLE hFindFile = INVALID_HANDLE_VALUE;
long n;
long nItemCount = 1;
LPTSTR szItem = 0;
WIN32_FIND_DATA stFindData = {0};
TRACE("Formatting Directories\n");
TRACE("Formatting Root Directory\n");
StarBurn_UDF_FormatTreeItemAsDirectory(&pstTreeDirectories[1], ++dwGuid, "", NULL);
TRACE("Formatting VIDEO_TS\n");
StarBurn_UDF_FormatTreeItemAsDirectory(&pstTreeDirectories[2], ++dwGuid, "VIDEO_TS", &pstTreeDirectories[1]);
TRACE("Formatting AUDIO_TS\n");
StarBurn_UDF_FormatTreeItemAsDirectory(&pstTreeDirectories[3], ++dwGuid, "AUDIO_TS", &pstTreeDirectories[1]);
sTreeItem = m_sTempDirectory + "\\VIDEO_TS\\VIDEO_TS.IFO";
arrSearchItems.Add(sTreeItem);
sTreeItem = m_sTempDirectory + "\\VIDEO_TS\\VIDEO_TS.VOB";
arrSearchItems.Add(sTreeItem);
sTreeItem = m_sTempDirectory + "\\VIDEO_TS\\VIDEO_TS.BUP";
arrSearchItems.Add(sTreeItem);
sTreeItem = m_sTempDirectory + "\\VIDEO_TS\\VTS_*.IFO";
arrSearchItems.Add(sTreeItem);
sTreeItem = m_sTempDirectory + "\\VIDEO_TS\\VTS_*.VOB";
arrSearchItems.Add(sTreeItem);
sTreeItem = m_sTempDirectory + "\\VIDEO_TS\\VTS_*.BUP";
arrSearchItems.Add(sTreeItem);
for (n = 0; n < arrSearchItems.GetSize(); n++)
{
hFindFile = FindFirstFile(arrSearchItems[n], &stFindData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
while (hFindFile != INVALID_HANDLE_VALUE)
{
TRACE("Formatting %s\\VIDEO_TS\\%s as %s\n", m_sTempDirectory, stFindData.cFileName, stFindData.cFileName);
nItemCount++;
if (pstTreeFiles)
{
pstTreeFiles = (PUDF_TREE_ITEM)::HeapReAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, pstTreeFiles, sizeof(UDF_TREE_ITEM) * (nItemCount));
}
else
{
pstTreeFiles = (PUDF_TREE_ITEM)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(UDF_TREE_ITEM) * (nItemCount));
}
if (pstTreeFiles)
{
szItem = (LPTSTR)Malloc(m_sTempDirectory.GetLength() + strlen("\\VIDEO_TS") + strlen(stFindData.cFileName) + 1, TRUE);
sprintf(szItem, "%s\\VIDEO_TS\\%s", m_sTempDirectory, stFindData.cFileName);
StarBurn_UDF_FormatTreeItemAsFile(&pstTreeFiles[nItemCount - 1], ++dwGuid, stFindData.cFileName, szItem, &pstTreeDirectories[2]);
Free(szItem);
szItem = 0;
}
if (!FindNextFile(hFindFile, &stFindData))
{
ASSERT(GetLastError() == ERROR_NO_MORE_FILES);
//close the find if we encounter any errors
FindClose(hFindFile);
hFindFile = INVALID_HANDLE_VALUE;
}
}
}
}
TRACE("Finished Formatting Files\n");
return nItemCount;
}
the ( i think) relevant log file entries
StarBurn:UDF_FileGetSizeInUCHARs(): File size in UCHARs 8192, file size in LBs 4
StarBurn:UDF_FileGetSizeInUCHARs(): File size in UCHARs 8192, file size in LBs 4
StarBurn:UDF_FileGetSizeInUCHARs(): File size in UCHARs 24576, file size in LBs 12
StarBurn:UDF_FileGetSizeInUCHARs(): File size in UCHARs 1020375040, file size in LBs 498230