updated minor memory management to avoid text corruption

This commit is contained in:
faraphel 2024-12-23 10:44:06 +01:00
parent 4e547635d8
commit 9c413c0edd
6 changed files with 17 additions and 15 deletions

View file

@ -9,14 +9,14 @@
namespace gns {
GnsNode::GnsNode(const GnsProject *project, std::string uuid, const std::vector<GnsPort>& ports) {
GnsNode::GnsNode(const GnsProject *project, const std::string& uuid, const std::vector<GnsPort>& ports) {
this->project = project;
this->uuid = std::move(uuid);
this->uuid = uuid;
this->ports = ports;
}
std::string GnsNode::getApiBase() const {
return this->project->getApiBase() + "nodes/" + this->uuid + "/";
return this->project->getApiBase() + "nodes/" + this->getUuid() + "/";
}
std::string GnsNode::getUuid() const {
@ -30,7 +30,7 @@ std::vector<GnsPort> GnsNode::getPorts() const {
void GnsNode::start() const {
// request the API endpoint
cpr::Url endpoint = this->getApiBase() + "start";
cpr::Response response = Post(endpoint);
const cpr::Response response = Post(endpoint);
// check for a valid response
if (response.error.code != cpr::ErrorCode::OK)

View file

@ -18,7 +18,7 @@ class GnsProject;
*/
class GnsNode {
public:
GnsNode(const GnsProject* project, std::string uuid, const std::vector<GnsPort>& ports);
GnsNode(const GnsProject* project, const std::string& uuid, const std::vector<GnsPort>& ports);
/**
* Get the base URL for the node API

View file

@ -10,13 +10,13 @@ using json = nlohmann::json;
namespace gns {
GnsProject::GnsProject(const GnsServer* server, std::string uuid) {
GnsProject::GnsProject(const GnsServer* server, const std::string& uuid) {
this->server = server;
this->uuid = std::move(uuid);
this->uuid = uuid;
}
std::string GnsProject::getApiBase() const {
return this->server->getApiBase() + "projects/" + this->uuid + "/";
return this->server->getApiBase() + "projects/" + this->getUuid() + "/";
}
std::string GnsProject::getUuid() const {

View file

@ -16,7 +16,7 @@ class GnsServer;
*/
class GnsProject {
public:
GnsProject(const GnsServer* server, std::string uuid);
GnsProject(const GnsServer* server, const std::string& uuid);
/**
* Get the base prefix for an API request

View file

@ -8,7 +8,7 @@ using json = nlohmann::json;
namespace gns {
GnsServer::GnsServer(const std::string &host, const std::uint16_t port) {
GnsServer::GnsServer(const std::string& host, const std::uint16_t port) {
this->host = host;
this->port = port;
}