mirror of
https://github.com/taglib/taglib.git
synced 2026-04-08 07:02:49 -04:00
Avoid using ByteVector::null where an empty vector is required.
ByteVector::null is not necessarily be empty or remains the same instance. Using it in a public header may lead to a linkage error.
This commit is contained in:
@ -196,7 +196,7 @@ void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int siz
|
||||
if(size > 24 && size <= (unsigned int)(file->length()))
|
||||
data = file->readBlock(size - 24);
|
||||
else
|
||||
data = ByteVector::null;
|
||||
data = ByteVector();
|
||||
}
|
||||
|
||||
ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/)
|
||||
@ -312,7 +312,7 @@ ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF:
|
||||
{
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(attributeData.toByteVector(ByteVector::null));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file)
|
||||
{
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(attributeData.toByteVector(ByteVector::null));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file
|
||||
{
|
||||
data.clear();
|
||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
||||
data.append(attributeData.toByteVector(ByteVector::null));
|
||||
data.append(attributeData.toByteVector(""));
|
||||
return BaseObject::render(file);
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,8 @@ ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other)
|
||||
ByteVector ASF::Picture::render() const
|
||||
{
|
||||
if(!isValid())
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
|
||||
return
|
||||
ByteVector((char)d->type) +
|
||||
ByteVector::fromUInt(d->picture.size(), false) +
|
||||
|
||||
@ -428,7 +428,7 @@ MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const
|
||||
StringList header = StringList::split(name, ":");
|
||||
if(header.size() != 3) {
|
||||
debug("MP4: Invalid free-form item name \"" + name + "\"");
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
ByteVector data;
|
||||
data.append(renderAtom("mean", ByteVector::fromUInt(0) + header[1].data(String::UTF8)));
|
||||
|
||||
@ -170,7 +170,7 @@ ByteVector Frame::frameID() const
|
||||
if(d->header)
|
||||
return d->header->frameID();
|
||||
else
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
TagLib::uint Frame::size() const
|
||||
|
||||
@ -92,7 +92,7 @@ ByteVector Ogg::File::packet(uint i)
|
||||
while(d->packetToPageMap.size() <= i) {
|
||||
if(!nextPage()) {
|
||||
debug("Ogg::File::packet() -- Could not find the requested packet.");
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ ByteVector Ogg::File::packet(uint i)
|
||||
if(pageIndex == d->pages.size()) {
|
||||
if(!nextPage()) {
|
||||
debug("Ogg::File::packet() -- Could not find the requested packet.");
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
}
|
||||
d->currentPacketPage = d->pages[pageIndex];
|
||||
|
||||
@ -117,7 +117,7 @@ TagLib::uint RIFF::File::chunkPadding(uint i) const
|
||||
ByteVector RIFF::File::chunkName(uint i) const
|
||||
{
|
||||
if(i >= chunkCount())
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
|
||||
return d->chunks[i].name;
|
||||
}
|
||||
@ -125,7 +125,7 @@ ByteVector RIFF::File::chunkName(uint i) const
|
||||
ByteVector RIFF::File::chunkData(uint i)
|
||||
{
|
||||
if(i >= chunkCount())
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
|
||||
seek(d->chunks[i].offset);
|
||||
return readBlock(d->chunks[i].size);
|
||||
|
||||
@ -55,7 +55,7 @@ ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &patt
|
||||
if(offset - previousOffset >= 1)
|
||||
l.append(v.mid(previousOffset, offset - previousOffset));
|
||||
else
|
||||
l.append(ByteVector::null);
|
||||
l.append(ByteVector());
|
||||
|
||||
previousOffset = offset + pattern.size();
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ FileName ByteVectorStream::name() const
|
||||
ByteVector ByteVectorStream::readBlock(ulong length)
|
||||
{
|
||||
if(length == 0)
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
|
||||
ByteVector v = d->data.mid(d->position, length);
|
||||
d->position += v.size();
|
||||
|
||||
@ -289,7 +289,7 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be
|
||||
}
|
||||
}
|
||||
|
||||
if(!before.isNull() && beforePreviousPartialMatch >= 0 && int(bufferSize()) > beforePreviousPartialMatch) {
|
||||
if(!before.isEmpty() && beforePreviousPartialMatch >= 0 && int(bufferSize()) > beforePreviousPartialMatch) {
|
||||
const int beforeOffset = (bufferSize() - beforePreviousPartialMatch);
|
||||
if(buffer.containsAt(before, 0, beforeOffset)) {
|
||||
seek(originalPosition);
|
||||
@ -305,7 +305,7 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be
|
||||
return bufferOffset + location;
|
||||
}
|
||||
|
||||
if(!before.isNull() && buffer.find(before) >= 0) {
|
||||
if(!before.isEmpty() && buffer.find(before) >= 0) {
|
||||
seek(originalPosition);
|
||||
return -1;
|
||||
}
|
||||
@ -314,7 +314,7 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be
|
||||
|
||||
previousPartialMatch = buffer.endsWithPartialMatch(pattern);
|
||||
|
||||
if(!before.isNull())
|
||||
if(!before.isEmpty())
|
||||
beforePreviousPartialMatch = buffer.endsWithPartialMatch(before);
|
||||
|
||||
bufferOffset += bufferSize();
|
||||
@ -387,7 +387,7 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b
|
||||
return bufferOffset + location;
|
||||
}
|
||||
|
||||
if(!before.isNull() && buffer.find(before) >= 0) {
|
||||
if(!before.isEmpty() && buffer.find(before) >= 0) {
|
||||
seek(originalPosition);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ namespace TagLib {
|
||||
*/
|
||||
long find(const ByteVector &pattern,
|
||||
long fromOffset = 0,
|
||||
const ByteVector &before = ByteVector::null);
|
||||
const ByteVector &before = ByteVector());
|
||||
|
||||
/*!
|
||||
* Returns the offset in the file that \a pattern occurs at or -1 if it can
|
||||
@ -181,7 +181,7 @@ namespace TagLib {
|
||||
*/
|
||||
long rfind(const ByteVector &pattern,
|
||||
long fromOffset = 0,
|
||||
const ByteVector &before = ByteVector::null);
|
||||
const ByteVector &before = ByteVector());
|
||||
|
||||
/*!
|
||||
* Insert \a data at position \a start in the file overwriting \a replace
|
||||
|
||||
@ -176,11 +176,11 @@ ByteVector FileStream::readBlock(ulong length)
|
||||
{
|
||||
if(!isOpen()) {
|
||||
debug("FileStream::readBlock() -- invalid file.");
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
if(length == 0)
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
|
||||
const ulong streamLength = static_cast<ulong>(FileStream::length());
|
||||
if(length > bufferSize() && length > streamLength)
|
||||
|
||||
@ -426,7 +426,7 @@ ByteVector String::data(Type t) const
|
||||
return v;
|
||||
}
|
||||
else {
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
case UTF16:
|
||||
{
|
||||
@ -472,7 +472,7 @@ ByteVector String::data(Type t) const
|
||||
default:
|
||||
{
|
||||
debug("String::data() - Invalid Type value.");
|
||||
return ByteVector::null;
|
||||
return ByteVector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user