new batch of delete operator missmatch

This commit is contained in:
Nikita Edel 2026-03-09 22:48:36 +01:00
parent 10ee2085ff
commit 66b31669c3
13 changed files with 27 additions and 17 deletions

View file

@ -285,12 +285,12 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB
PIXBeginNamedEvent(0,"Setting Block data");
chunk->setBlockData(blockData);
PIXEndNamedEvent();
delete blockData.data;
delete[] blockData.data; //4jcraft changed to array delete
chunk->recalcHeightmapOnly();
PIXBeginNamedEvent(0,"Setting Data data");
chunk->setDataData(dataData);
PIXEndNamedEvent();
delete dataData.data;
delete[] dataData.data; //4jcraft, same here
// A basic pass through to roughly do the lighting. At this point of post-processing, we don't have all the neighbouring chunks loaded in,
// so any lighting here should be things that won't propagate out of this chunk.

View file

@ -19,4 +19,4 @@ public:
~LookAtTileHint();
virtual bool onLookAt(int id, int iData=0);
};
};

View file

@ -16,4 +16,4 @@ public:
~TakeItemHint();
virtual bool onTake( std::shared_ptr<ItemInstance> item );
};
};

View file

@ -50,4 +50,4 @@ public:
virtual bool onLookAtEntity(eINSTANCEOF type);
virtual int tick();
virtual bool allowFade() { return m_allowFade; }
};
};

View file

@ -160,7 +160,7 @@ TileRenderer::TileRenderer( LevelSource* level, int xMin, int yMin, int zMin, un
TileRenderer::~TileRenderer()
{
delete cache;
delete[] cache; //4jcraft, changed to []
}
TileRenderer::TileRenderer( LevelSource* level )

View file

@ -15,7 +15,11 @@ BufferedOutputStream::BufferedOutputStream(OutputStream *out, int size)
BufferedOutputStream::~BufferedOutputStream()
{
delete buf.data;
//4jcraft, changed to [], deallocates internal buffer
//TODO: ArrayWithLength.h doesnt have a destructor.
//this wouldnt need to be done manually.
//but for some reason the destructor is commented out in the source code?
delete[] buf.data;
}
//Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.

View file

@ -342,6 +342,6 @@ std::shared_ptr<Packet> MapItem::getUpdatePacket(std::shared_ptr<ItemInstance> i
if (data.data == NULL || data.length == 0) return nullptr;
std::shared_ptr<Packet> retval = std::shared_ptr<Packet>(new ComplexItemDataPacket((short) Item::map->id, (short) itemInstance->getAuxValue(), data));
delete data.data;
delete[] data.data; //4jcraft, changed to []
return retval;
}

View file

@ -123,7 +123,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(std::shared_ptr<Item
memcpy(lastSentDecorations.data, data.data, data.length);
return data;
}
delete data.data;
delete[] data.data; //4jcraft, changed to []
}
std::shared_ptr<ServerPlayer> servPlayer = std::dynamic_pointer_cast<ServerPlayer>(player);
for (int d = 0; d < 10; d++)

View file

@ -16,7 +16,12 @@ AwardStatPacket::AwardStatPacket(int statId, int count)
{
this->statId = statId;
this->m_paramData.data = (uint8_t *) new int(count);
// 4jcraft, changed from new int(count); to new int[1];
// and initializing the array with count
// reason: .data needs to be delete with delete[] but its
// allocated with new, not new T[]
this->m_paramData.data = (uint8_t *) new int[1];
((int*)this->m_paramData.data)[0] = count;
this->m_paramData.length = sizeof(int);
}
@ -30,7 +35,7 @@ AwardStatPacket::~AwardStatPacket()
{
if (m_paramData.data != NULL)
{
delete [] m_paramData.data;
delete[] m_paramData.data;
m_paramData.data = NULL;
}
}

View file

@ -16,7 +16,7 @@ RemoveEntitiesPacket::RemoveEntitiesPacket(intArray ids)
RemoveEntitiesPacket::~RemoveEntitiesPacket()
{
delete ids.data;
delete[] ids.data; //4jcraft, changed to []
}
void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException

View file

@ -12,14 +12,14 @@ AABB::ThreadStorage *AABB::tlsDefault = NULL;
AABB::ThreadStorage::ThreadStorage()
{
pool = new AABB[POOL_SIZE];
pool = new AABB[POOL_SIZE]; //4jcraft, needs to be deleted with delete[]
poolPointer = 0;
}
AABB::ThreadStorage::~ThreadStorage()
{
delete pool;
delete[] pool; //4jcraft, changed to []
}
void AABB::CreateNewThreadStorage()

View file

@ -218,7 +218,7 @@ void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h,
{
BiomeArray tmp = cache->getBiomeBlockAt(x, z);
System::arraycopy(tmp, 0, &biomes, 0, w * h);
delete tmp.data; // MGH - added, the caching creates this array from the indices now.
delete[] tmp.data; // MGH - added, the caching creates this array from the indices now. //4jcraft made it array delete
//return biomes;
}
@ -635,4 +635,4 @@ bool BiomeSource::getIsMatch(float *frac)
// Consider as suitable if we've got all the critical ones, and in total 9 or more - currently there's 8 critical so this just forces at least 1 more others
return ( typeCount >= 9 );
}
}

View file

@ -188,7 +188,8 @@ LevelChunk *TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs)
levelChunk->recalcHeightmap();
//delete blocks.data; // Don't delete the blocks as the array data is actually owned by the chunk now
delete biomes.data;
//4jcraft changed to []
delete[] biomes.data;
return levelChunk;
}