Commit 287ead74 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #219 from undingen/mem_leak

fix memory leak
parents 5945006b b63867bd
......@@ -250,13 +250,11 @@ extern "C" Box* strMul(BoxedString* lhs, Box* rhs) {
// TODO: use createUninitializedString and getWriteableStringContents
int sz = lhs->s.size();
char* buf = new char[sz * n + 1];
std::string buf(sz * n, '\0');
for (int i = 0; i < n; i++) {
memcpy(buf + (sz * i), lhs->s.c_str(), sz);
memcpy(&buf[sz * i], lhs->s.c_str(), sz);
}
buf[sz * n] = '\0';
return new BoxedString(buf);
return new BoxedString(std::move(buf));
}
extern "C" Box* strLt(BoxedString* lhs, Box* rhs) {
......
......@@ -587,7 +587,7 @@ Box* sliceRepr(BoxedSlice* self) {
BoxedString* stop = static_cast<BoxedString*>(repr(self->stop));
BoxedString* step = static_cast<BoxedString*>(repr(self->step));
std::string s = "slice(" + start->s + ", " + stop->s + ", " + step->s + ")";
return new BoxedString(s);
return new BoxedString(std::move(s));
}
Box* typeRepr(BoxedClass* self) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment