Skip to content

Commit

Permalink
fix compilation, remove Debug.h include
Browse files Browse the repository at this point in the history
  • Loading branch information
matth-x committed Aug 12, 2024
1 parent bada726 commit 4a980f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
10 changes: 0 additions & 10 deletions src/MicroOcpp/Core/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include <stddef.h>

#include <MicroOcpp/Debug.h> //only for evaluation. Remove before merging on main

#ifndef MO_OVERRIDE_ALLOCATION
#define MO_OVERRIDE_ALLOCATION 0
#endif
Expand Down Expand Up @@ -145,11 +143,9 @@ class AllocOverrider {
}
public:
void *operator new(size_t size) {
MO_DBG_VERBOSE("AllocOverrider new %zu B", size);
return MO_MALLOC(nullptr, size);
}
void operator delete(void * ptr) {
MO_DBG_VERBOSE("AllocOverrider delete");
MO_FREE(ptr);
}

Expand Down Expand Up @@ -221,7 +217,6 @@ struct Allocator {
}

T *allocate(size_t count) {
MO_DBG_VERBOSE("Allocator allocate %zu B (%s)", sizeof(T) * count, tag ? tag : "unspecified");
return static_cast<T*>(
MO_MALLOC(
#if MO_ENABLE_HEAP_PROFILER
Expand All @@ -233,7 +228,6 @@ struct Allocator {
}

void deallocate(T *ptr, size_t count) {
MO_DBG_VERBOSE("Allocator deallocate %zu B (%s)", sizeof(T) * count, tag ? tag : "unspecified");
MO_FREE(ptr);
}

Expand Down Expand Up @@ -357,7 +351,6 @@ class ArduinoJsonAllocator {
}

void *allocate(size_t size) {
MO_DBG_VERBOSE("ArduinoJsonAllocator allocate %zu B (%s)", size, tag ? tag : "unspecified");
return MO_MALLOC(
#if MO_ENABLE_HEAP_PROFILER
tag,
Expand All @@ -367,7 +360,6 @@ class ArduinoJsonAllocator {
size);
}
void deallocate(void *ptr) {
MO_DBG_VERBOSE("ArduinoJsonAllocator deallocate");
MO_FREE(ptr);
}
};
Expand All @@ -376,7 +368,6 @@ using MemJsonDoc = BasicJsonDocument<ArduinoJsonAllocator>;

template<class T, typename ...Args>
T *mo_mem_new(const char *tag, Args&& ...args) {
MO_DBG_VERBOSE("mo_mem_new %zu B (%s)", sizeof(T), tag ? tag : "unspecified");
if (auto ptr = MO_MALLOC(tag, sizeof(T))) {
return new(ptr) T(std::forward<Args>(args)...);
}
Expand All @@ -385,7 +376,6 @@ T *mo_mem_new(const char *tag, Args&& ...args) {

template<class T>
void mo_mem_delete(T *ptr) {
MO_DBG_VERBOSE("mo_mem_delete");
if (ptr) {
ptr->~T();
MO_FREE(ptr);
Expand Down
1 change: 1 addition & 0 deletions src/MicroOcpp/Model/Authorization/AuthorizationData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#if MO_ENABLE_LOCAL_AUTH

#include <MicroOcpp/Model/Authorization/AuthorizationData.h>
#include <MicroOcpp/Debug.h>

using namespace MicroOcpp;

Expand Down
14 changes: 7 additions & 7 deletions tests/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ TEST_CASE( "C++ API test" ) {
setOnSendConf("StatusNotification", [c = &checkpoints[ncheck++]] (JsonObject) {*c = true;});
sendRequest("DataTransfer", [c = &checkpoints[ncheck++]] () {
*c = true;
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
doc->to<JsonObject>();
return doc;
}, [c = &checkpoints[ncheck++]] (JsonObject) {*c = true;});
setRequestHandler("DataTransfer", [c = &checkpoints[ncheck++]] (JsonObject) {*c = true;}, [c = &checkpoints[ncheck++]] () {
*c = true;
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
doc->to<JsonObject>();
return doc;
});
Expand Down Expand Up @@ -145,13 +145,13 @@ TEST_CASE( "C++ API test" ) {
REQUIRE(isOperative());

sendRequest("UnlockConnector", [] () {
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
(*doc)["connectorId"] = 1;
return doc;
}, [] (JsonObject) {});

sendRequest("Reset", [] () {
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
(*doc)["type"] = "Hard";
return doc;
}, [] (JsonObject) {});
Expand Down Expand Up @@ -333,18 +333,18 @@ TEST_CASE( "C API test" ) {
REQUIRE(ocpp_isOperative_m(2));

sendRequest("UnlockConnector", [] () {
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
(*doc)["connectorId"] = 1;
return doc;
}, [] (JsonObject) {});
sendRequest("UnlockConnector", [] () {
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
(*doc)["connectorId"] = 2;
return doc;
}, [] (JsonObject) {});

sendRequest("Reset", [] () {
auto doc = MicroOcpp::makeMemJsonDoc(getMemoryTag(), JSON_OBJECT_SIZE(1));
auto doc = MicroOcpp::makeMemJsonDoc("UnitTests", JSON_OBJECT_SIZE(1));
(*doc)["type"] = "Hard";
return doc;
}, [] (JsonObject) {});
Expand Down

0 comments on commit 4a980f7

Please sign in to comment.