]> granicus.if.org Git - taglib/commitdiff
Avoid an implicit const cast.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 21 Dec 2015 04:06:43 +0000 (13:06 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 21 Dec 2015 04:06:43 +0000 (13:06 +0900)
taglib/mpeg/id3v2/id3v2frame.cpp

index 8960ffe2d97e6f9407c5cb0d3f18ed4ed81ed095..52180447fbb7be043f916a9134e8328c5a957eb9 100644 (file)
@@ -265,17 +265,19 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const
     if(inflateInit(&stream) != Z_OK)
       return ByteVector();
 
-    stream.avail_in = (uLongf) frameData.size() - frameDataOffset;
-    stream.next_in = (Bytef *) frameData.data() + frameDataOffset;
+    ByteVector inData = frameData;
+
+    stream.avail_in = static_cast<uInt>(inData.size() - frameDataOffset);
+    stream.next_in = reinterpret_cast<Bytef *>(inData.data() + frameDataOffset);
 
     static const unsigned int chunkSize = 1024;
 
-    ByteVector data;
+    ByteVector outData;
     ByteVector chunk(chunkSize);
 
     do {
-      stream.avail_out = (uLongf) chunk.size();
-      stream.next_out = (Bytef *) chunk.data();
+      stream.avail_out = static_cast<uInt>(chunk.size());
+      stream.next_out = reinterpret_cast<Bytef *>(chunk.data());
 
       int result = inflate(&stream, Z_NO_FLUSH);
 
@@ -290,15 +292,15 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const
         return ByteVector();
       }
 
-      data.append(stream.avail_out == 0 ? chunk : chunk.mid(0, chunk.size() - stream.avail_out));
+      outData.append(stream.avail_out == 0 ? chunk : chunk.mid(0, chunk.size() - stream.avail_out));
     } while(stream.avail_out == 0);
 
     inflateEnd(&stream);
 
-    if(frameDataLength != data.size())
+    if(frameDataLength != outData.size())
       debug("frameDataLength does not match the data length returned by zlib");
 
-    return data;
+    return outData;
   }
   else
 #endif