Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix memory leak #311

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/DbResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ cpp11::list DbResult::fetch(const int n_max) {
}

cpp11::list DbResult::get_column_info() {
auto out = impl->get_column_info();
// Memory leak if cpp11::writable::list is returned?
// https://github.com/r-dbi/RMariaDB/issues/309
cpp11::writable::list out = impl->get_column_info();

out.attr("row.names") = cpp11::integers({NA_INTEGER, static_cast<int>(-Rf_length(out[0]))});
out.attr("class") = "data.frame";
Expand Down
2 changes: 1 addition & 1 deletion src/MariaResultImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MariaResultImpl {

virtual void bind(const cpp11::list& params) = 0;

virtual cpp11::writable::list get_column_info() = 0;
virtual cpp11::list get_column_info() = 0;

virtual cpp11::list fetch(int n_max = -1) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/MariaResultPrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void MariaResultPrep::bind(const cpp11::list& params) {
bound_ = true;
}

cpp11::writable::list MariaResultPrep::get_column_info() {
cpp11::list MariaResultPrep::get_column_info() {
using namespace cpp11::literals;
cpp11::writable::strings names(nCols_), types(nCols_);
for (int i = 0; i < nCols_; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/MariaResultPrep.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MariaResultPrep : boost::noncopyable, public MariaResultImpl {

virtual void bind(const cpp11::list& params);

virtual cpp11::writable::list get_column_info();
virtual cpp11::list get_column_info();

virtual cpp11::list fetch(int n_max = -1);

Expand Down
2 changes: 1 addition & 1 deletion src/MariaResultSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void MariaResultSimple::bind(const cpp11::list& /*params*/) {
cpp11::stop("This query is not supported by the prepared statement protocol, no parameters can be bound.");
}

cpp11::writable::list MariaResultSimple::get_column_info() {
cpp11::list MariaResultSimple::get_column_info() {
using namespace cpp11::literals;
cpp11::writable::strings names(0_xl), types(0_xl);

Expand Down
2 changes: 1 addition & 1 deletion src/MariaResultSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MariaResultSimple : boost::noncopyable, public MariaResultImpl {

virtual void bind(const cpp11::list& params);

virtual cpp11::writable::list get_column_info();
virtual cpp11::list get_column_info();

virtual cpp11::list fetch(int n_max = -1);

Expand Down
4 changes: 3 additions & 1 deletion src/MariaUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ void df_s3(const cpp11::list& df, const std::vector<MariaFieldType>& types) {
}
}

cpp11::writable::list df_create(const std::vector<MariaFieldType>& types, const std::vector<std::string>& names, int n) {
// Memory leak if cpp11::writable::list is returned?
// https://github.com/r-dbi/RMariaDB/issues/309
cpp11::list df_create(const std::vector<MariaFieldType>& types, const std::vector<std::string>& names, int n) {
R_xlen_t p = types.size();

cpp11::writable::list out(p);
Expand Down
2 changes: 1 addition & 1 deletion src/MariaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cpp11::list df_resize(const cpp11::list& df, int n);
// Set up S3 classes correctly
void df_s3(const cpp11::list& df, const std::vector<MariaFieldType>& types);

cpp11::writable::list df_create(const std::vector<MariaFieldType>& types,
cpp11::list df_create(const std::vector<MariaFieldType>& types,
const std::vector<std::string>& names,
int n);

Expand Down
Loading