Skip to content
Merged
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
12 changes: 4 additions & 8 deletions src/StanEstimators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,22 @@ RcppExport SEXP call_stan_(SEXP options_vector, SEXP ll_fun, SEXP grad_fun) {
internal::grad_fun = Rcpp::Function(grad_fun);
std::vector<std::string> options = Rcpp::as<std::vector<std::string>>(options_vector);
int argc = 1 + options.size();
char** argv = new char*[argc];
const char* argv[argc];

// Read in the name
std::string name = "\0";
argv[0] = new char[name.size() + 1];
strcpy(argv[0], name.c_str());
argv[0] = name.c_str();

if (options.size() > 0) {
// internal counter
int counter = 1;

// Read List into vector of char arrays
for (int i = 0; i < options.size(); ++i) {
std::string val = std::string(options[i]);
argv[counter] = new char[val.size() + 1];
strcpy(argv[counter++], val.c_str());
argv[counter++] = options[i].c_str();
}
}
const char** argv2 = const_cast<const char**>(argv);
return Rcpp::wrap(cmdstan::command(argc, argv2));
return Rcpp::wrap(cmdstan::command(argc, argv));
END_RCPP
}

Expand Down
Loading