[matroska] r957 - in trunk/libebml: ebml src

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: mosu
Date: 2004-11-30 18:41:57 +0300 (Tue, 30 Nov 2004)
New Revision: 957

Modified:
   trunk/libebml/ebml/EbmlBinary.h
   trunk/libebml/src/EbmlBinary.cpp
Log:
Use malloc() and free() instead of new[] and delete[] where the lib might deal with pointers that have been allocated by the app, or where the app has allocated the memory. Reason: new[]ed memory cannot be realloc()ed.

Modified: trunk/libebml/ebml/EbmlBinary.h
===================================================================
--- trunk/libebml/ebml/EbmlBinary.h	2004-11-28 17:43:08 UTC (rev 956)
+++ trunk/libebml/ebml/EbmlBinary.h	2004-11-30 15:41:57 UTC (rev 957)
@@ -76,8 +76,8 @@
 		
 		void CopyBuffer(const binary *Buffer, const uint32 BufferSize) {
 			if (Data != NULL)
-				delete Data;
-			Data = new binary[BufferSize];
+				free(Data);
+			Data = (binary *)malloc(BufferSize * sizeof(binary));
 			memcpy(Data, Buffer, BufferSize);
 			Size = BufferSize;
 			bValueIsSet = true;

Modified: trunk/libebml/src/EbmlBinary.cpp
===================================================================
--- trunk/libebml/src/EbmlBinary.cpp	2004-11-28 17:43:08 UTC (rev 956)
+++ trunk/libebml/src/EbmlBinary.cpp	2004-11-30 15:41:57 UTC (rev 957)
@@ -53,14 +53,15 @@
 	if (ElementToClone.Data == NULL)
 		Data = NULL;
 	else {
-		Data = new binary[Size];
+		Data = (binary *)malloc(Size * sizeof(binary));
+		assert(Data != NULL);
 		memcpy(Data, ElementToClone.Data, Size);
 	}
 }
 
 EbmlBinary::~EbmlBinary(void) {
 	if(Data)
-		delete[] Data;
+		free(Data);
 }
 
 uint32 EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault)
@@ -81,7 +82,7 @@
 uint64 EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
 {
 	if (Data != NULL)
-		delete Data;
+		free(Data);
 	
 	if (ReadFully == SCOPE_NO_DATA)
 	{
@@ -89,7 +90,8 @@
 		return Size;
 	}
 
-	Data = new binary[Size];
+	Data = (binary *)malloc(Size * sizeof(binary));
+	assert(Data != NULL);
 	bValueIsSet = true;
 	return input.read(Data, Size);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.