Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit f9f9686

Browse files
committed
Input can't have a default move ctor, because it holds a raw pointer;
1 parent 1d1b73f commit f9f9686

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/input.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "input.h"
2+
#include <iostream>
23

34
namespace lib_ruby_parser
45
{
@@ -15,10 +16,18 @@ namespace lib_ruby_parser
1516
this->ptr = ptr;
1617
}
1718

19+
Input::Input(Input &&input)
20+
{
21+
this->ptr = input.ptr;
22+
input.ptr = nullptr;
23+
}
24+
1825
Input::~Input()
1926
{
20-
// FIXME
21-
// input_free(this->ptr);
27+
if (this->ptr != nullptr)
28+
{
29+
input_free(this->ptr);
30+
}
2231
}
2332

2433
const char *Input::source()

src/input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace lib_ruby_parser
1515
Input() = default;
1616
explicit Input(void *);
1717
Input(const Input &) = delete;
18-
Input(Input &&) = default;
18+
Input(Input &&);
1919
~Input();
2020

2121
const char *source();

0 commit comments

Comments
 (0)