[matroska] r756 - trunk/DvdMenuXtractor
[email protected] Wed, 8 Sep 2004 16:58:18 +0400 (MSD)
Newsgroups
gmane.comp.multimedia.matroska.cvs
Message-ID
<[email protected] >
Author: robux4
Date: 2004-09-08 16:58:17 +0400 (Wed, 08 Sep 2004)
New Revision: 756
Modified:
trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
Log:
rework the allocation strategy
Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-09-08 09:50:41 UTC (rev 755)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-09-08 12:58:17 UTC (rev 756)
@@ -787,17 +787,17 @@
{
if (command_tbl)
{
+ unsigned char *_buf = (unsigned char*) malloc(1+command_tbl->nr_of_pre * 8);
+
// Pre commands
if (command_tbl->nr_of_pre)
{
XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
lvl++;
XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>1</ChapProcessTime>");
- unsigned char *_buf= (unsigned char*) malloc(1+command_tbl->nr_of_pre * 8);
_buf[0] = command_tbl->nr_of_pre;
memcpy(&_buf[1], command_tbl->pre_cmds, command_tbl->nr_of_pre * 8);
XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+command_tbl->nr_of_pre * 8)+"</ChapProcessCommand>");
- free(_buf);
lvl--;
XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
}
@@ -808,11 +808,10 @@
XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
lvl++;
XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>1</ChapProcessTime>");
- unsigned char *_buf= (unsigned char*) malloc(1+command_tbl->nr_of_cell * 8);
+ _buf = (unsigned char*) realloc(_buf, 1+command_tbl->nr_of_cell * 8);
_buf[0] = command_tbl->nr_of_cell;
memcpy(&_buf[1], command_tbl->cell_cmds, command_tbl->nr_of_cell * 8);
XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+command_tbl->nr_of_cell * 8)+"</ChapProcessCommand>");
- free(_buf);
lvl--;
XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
}
@@ -823,14 +822,14 @@
XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
lvl++;
XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>2</ChapProcessTime>");
- unsigned char *_buf= (unsigned char*) malloc(1+command_tbl->nr_of_post * 8);
+ _buf = (unsigned char*) realloc(_buf, 1+command_tbl->nr_of_post * 8);
_buf[0] = command_tbl->nr_of_post;
memcpy(&_buf[1], command_tbl->post_cmds, command_tbl->nr_of_post * 8);
XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+command_tbl->nr_of_post * 8)+"</ChapProcessCommand>");
- free(_buf);
lvl--;
XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
}
+ free(_buf);
}
}
@@ -859,7 +858,7 @@
XmlFile.AddLine("<Chapters>");
lvl++;
- XmlFile.AddLine(IndentString(lvl)+"<EditionEntry>");
+ XmlFile.AddLine(IndentString(lvl)+"<EditionEntry>");
lvl++;
XmlFile.AddLine(IndentString(lvl)+"<EditionUID>"+CreateUID()+"</EditionUID>");
XmlFile.AddLine(IndentString(lvl)+"<EditionProcessed>1</EditionProcessed>"); // DVD style menu
@@ -867,8 +866,8 @@
// Write the first play PGC
if (IfoFile->FirstPlayPGC())
{
- XmlFile.AddLine(IndentString(lvl)+"<!-- First Play PGC -->");
lvl++;
+ XmlFile.AddLine(IndentString(lvl)+"<!-- First Play PGC -->");
XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
lvl++;
wxString _myUID = CreateUID();
@@ -899,7 +898,7 @@
}
lvl--;
- XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
+ XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
lvl--;
XmlFile.AddLine("</Chapters>");
#if 0