[xiph-commits] r8042 - in trunk/oggdsf/src: lib/core/ogg/libOOOgg
tests/testMuxDemux
illiminable at motherfish-iii.xiph.org
illiminable at motherfish-iii.xiph.org
Sun Oct 17 09:18:58 PDT 2004
Author: illiminable
Date: 2004-10-17 09:18:57 -0700 (Sun, 17 Oct 2004)
New Revision: 8042
Modified:
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.h
trunk/oggdsf/src/tests/testMuxDemux/OggPageFileWriter.cpp
Log:
* OggPage class leak free.
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.cpp 2004-10-17 16:07:28 UTC (rev 8041)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.cpp 2004-10-17 16:18:57 UTC (rev 8042)
@@ -31,7 +31,7 @@
#include "StdAfx.h"
#include "oggpage.h"
-
+//LEACK CHECKED::: 20041018 - OK.
OggPage::OggPage(void)
{
mHeader = new OggPageHeader; //Deleted in destructor.
@@ -45,10 +45,13 @@
delete mPacketList[i];
}
}
+
+//Retusn a view on the header only
OggPageHeader* OggPage::header() {
return mHeader;
}
+//returns a view on the packet only.
OggPacket* OggPage::getPacket(unsigned long inPacketNo) {
if (inPacketNo < numPackets()) {
return mPacketList[inPacketNo];
@@ -56,7 +59,7 @@
return NULL;
}
}
-
+//Returns a view on the packet only
StampedOggPacket* OggPage::getStampedPacket(unsigned long inPacketNo) {
if (inPacketNo < numPackets()) {
return mPacketList[inPacketNo];
@@ -64,11 +67,13 @@
return NULL;
}
}
+
+//Gives away a pointer to the caller.
OggPage* OggPage::clone() {
OggPage* retClone = new OggPage;
retClone->mHeader = mHeader->clone();
for (size_t i = 0; i < mPacketList.size(); i++) {
- retClone->mPacketList.push_back(mPacketList[i]);
+ retClone->mPacketList.push_back((StampedOggPacket*)mPacketList[i]->clone()); //The cloned new packet is deleted in the destructor
}
return retClone;
@@ -78,8 +83,9 @@
return (unsigned long)mPacketList.size();
}
+//Gives a pointer to the caller, it must delete it.
unsigned char* OggPage::createRawPageData() {
- unsigned char* locPage = new unsigned char[mHeader->pageSize()];
+ unsigned char* locPage = new unsigned char[mHeader->pageSize()]; //Given to the caller
mHeader->rawData(locPage, mHeader->pageSize());
unsigned long locOffset = mHeader->headerSize();
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.h 2004-10-17 16:07:28 UTC (rev 8041)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPage.h 2004-10-17 16:18:57 UTC (rev 8042)
@@ -51,7 +51,7 @@
//Constructors
OggPage(void);
- ~OggPage(void);
+ virtual ~OggPage(void);
//
//Cloning
@@ -65,8 +65,8 @@
//
//IOggPackSource Implementation
- OggPacket* getPacket(unsigned long inPacketNo);
- unsigned long numPackets();
+ virtual OggPacket* getPacket(unsigned long inPacketNo);
+ virtual unsigned long numPackets();
//
//Packet access
@@ -87,4 +87,8 @@
vector<StampedOggPacket*> mPacketList;
OggPageHeader* mHeader;
//
+
+private:
+ OggPage& operator=(const OggPage& other); /* Don't assign me */
+ OggPage(const OggPage& other); /* Don't copy me */
};
Modified: trunk/oggdsf/src/tests/testMuxDemux/OggPageFileWriter.cpp
===================================================================
--- trunk/oggdsf/src/tests/testMuxDemux/OggPageFileWriter.cpp 2004-10-17 16:07:28 UTC (rev 8041)
+++ trunk/oggdsf/src/tests/testMuxDemux/OggPageFileWriter.cpp 2004-10-17 16:18:57 UTC (rev 8042)
@@ -14,5 +14,6 @@
unsigned char* locPageBytes = inOggPage->createRawPageData();
mFile.write((const char*) locPageBytes, inOggPage->pageSize());
+ delete [] locPageBytes;
return true;
}
\ No newline at end of file
More information about the commits
mailing list