[xiph-commits] r8043 - trunk/oggdsf/src/lib/core/ogg/libOOOgg

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Sun Oct 17 09:23:39 PDT 2004


Author: illiminable
Date: 2004-10-17 09:23:38 -0700 (Sun, 17 Oct 2004)
New Revision: 8043

Modified:
   trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.cpp
   trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h
Log:
* PageHeader leak free

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.cpp	2004-10-17 16:18:57 UTC (rev 8042)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.cpp	2004-10-17 16:23:38 UTC (rev 8043)
@@ -56,6 +56,7 @@
 	delete[] mSegmentTable;
 }
 
+//Gives a pointer to the caller.
 OggPageHeader* OggPageHeader::clone() {
 
 	OggPageHeader* retClone = new OggPageHeader();
@@ -72,10 +73,10 @@
 	retClone->mStructureVersion = mStructureVersion;
 
 	//Copy the segment table.
-	unsigned char* locBuff = new unsigned char[mNumPageSegments];
+	unsigned char* locBuff = new unsigned char[mNumPageSegments];			//Stored in the returned classes member variable, deleted in it's destructor
 	memcpy((void*)locBuff, (const void*)mSegmentTable, mNumPageSegments);
 	retClone->mSegmentTable = locBuff;
-	locBuff = NULL;
+	locBuff = NULL;		//Given away.
 	//
 
 	return retClone;
@@ -242,7 +243,7 @@
 }
 //Copies the data from the pointer it is given.
 void OggPageHeader::setSegmentTable(const unsigned char* inPtr, unsigned char inNumSegs) {
-	unsigned char* locSegTable = new unsigned char[inNumSegs];
+	unsigned char* locSegTable = new unsigned char[inNumSegs];		//This is stored in the member variable and deleted in the destructor.
 	memcpy((void*)locSegTable, (const void*)inPtr, inNumSegs);
 	delete[] mSegmentTable;
 	mSegmentTable = locSegTable;

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h	2004-10-17 16:18:57 UTC (rev 8042)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h	2004-10-17 16:23:38 UTC (rev 8043)
@@ -40,7 +40,7 @@
 using namespace std;
 
 #define OGG_CAPTURE_PATTERN "Oggs"
-class LIBOOOGG_API OggPageHeader
+class LIBOOOGG_API OggPageHeader			//Do not derive - or needs virtual destructor.
 {
 public:
 	OggPageHeader(void);
@@ -149,5 +149,7 @@
 	//OggSegmentTable* mSegmentTable;
 
 	ePageState mPageState;
-
+private:
+	OggPageHeader& operator=(const OggPageHeader& other);  /* Don't assign me */
+	OggPageHeader(const OggPageHeader& other); /* Don't copy me */
 };



More information about the commits mailing list