Skip to content

Commit c6422e0

Browse files
authoredJul 10, 2020
Remove std::shared_ptr use in TileLayer (#10090)
1 parent b1ff04e commit c6422e0

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
 

Diff for: ‎src/client/tile.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2525
#include <string>
2626
#include <vector>
2727
#include <SMaterial.h>
28-
#include <memory>
2928
#include "util/numeric.h"
3029
#include "config.h"
3130

@@ -284,7 +283,7 @@ struct TileLayer
284283
//! If true, the tile has its own color.
285284
bool has_color = false;
286285

287-
std::shared_ptr<std::vector<FrameSpec>> frames = nullptr;
286+
std::vector<FrameSpec> *frames = nullptr;
288287

289288
/*!
290289
* The color of the tile, or if the tile does not own

Diff for: ‎src/nodedef.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ ContentFeatures::ContentFeatures()
317317
reset();
318318
}
319319

320+
ContentFeatures::~ContentFeatures()
321+
{
322+
#ifndef SERVER
323+
for (u16 j = 0; j < 6; j++) {
324+
delete tiles[j].layers[0].frames;
325+
delete tiles[j].layers[1].frames;
326+
}
327+
for (u16 j = 0; j < CF_SPECIAL_COUNT; j++)
328+
delete special_tiles[j].layers[0].frames;
329+
#endif
330+
}
331+
320332
void ContentFeatures::reset()
321333
{
322334
/*
@@ -662,7 +674,7 @@ static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
662674
} else {
663675
std::ostringstream os(std::ios::binary);
664676
if (!layer->frames) {
665-
layer->frames = std::make_shared<std::vector<FrameSpec>>();
677+
layer->frames = new std::vector<FrameSpec>();
666678
}
667679
layer->frames->resize(frame_count);
668680

Diff for: ‎src/nodedef.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ struct ContentFeatures
409409
*/
410410

411411
ContentFeatures();
412-
~ContentFeatures() = default;
412+
~ContentFeatures();
413413
void reset();
414414
void serialize(std::ostream &os, u16 protocol_version) const;
415415
void deSerialize(std::istream &is);

0 commit comments

Comments
 (0)