fix mem leak and -Wall warnings

This commit is contained in:
Christopher Mosher 2013-12-14 01:49:50 -05:00
parent a10889ecd8
commit e05f941086
3 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
CXXFLAGS=-g -std=c++11
CXXFLAGS=-g -std=c++11 -Wall -O4
SRCS = v6502.cpp trans.cpp SegmentCache.cpp TransNetwork.cpp Trace.cpp Circuit.cpp StateCalculator.cpp Cpu6502.cpp
OBJS = $(SRCS:.cpp=.o)

View File

@ -17,10 +17,11 @@
class SegmentCache {
public:
SegmentCache() {
SegmentCache() : c(nullptr) {
}
virtual ~SegmentCache() {
delete this->c;
}
Segment* getOrAdd(const std::string& id);
@ -162,11 +163,11 @@ public:
P0(P0), P1(P1), P2(P2), P3(P3), P4(P4), /* no P5 */ P6(P6), P7(P7),
S0(S0), S1(S1), S2(S2), S3(S3), S4(S4), S5(S5), S6(S6), S7(S7) {
}
~Common();
~Common() {}
private:
Common(const Common&);
Common& operator=(const Common&);
Common(const Common&) = delete;
Common& operator=(const Common&) = delete;
};
void initCommon();
@ -186,8 +187,8 @@ public:
private:
std::map<const std::string, std::shared_ptr<Segment > > cache;
SegmentCache(const SegmentCache&);
SegmentCache& operator=(const SegmentCache&);
SegmentCache(const SegmentCache&) = delete;
SegmentCache& operator=(const SegmentCache&) = delete;
};
#endif /* SEGMENTCACHE_H */

View File

@ -19,9 +19,9 @@ public:
std::set<Trans*> gates;
std::set<Trans*> c1c2s;
bool pullup;
bool pulldown;
bool on;
bool pulldown;
bool pullup;
bool vss;
bool vcc;
@ -48,7 +48,7 @@ public:
public:
Trans(Segment* c1, Segment* gate, Segment* c2) : on(false), c1(c1), gate(gate), c2(c2) {
Trans(Segment* c1, Segment* gate, Segment* c2) : c1(c1), gate(gate), c2(c2), on(false) {
c1->c1c2s.insert(this);
gate->gates.insert(this);
c2->c1c2s.insert(this);