Skip to content

Commit 325d04c

Browse files
committed
UPD | chunked #7
1 parent 9cb5663 commit 325d04c

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

include/ManapiUtils.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ namespace manapi::sockets {
3838
}
3939

4040
namespace manapi::memory {
41+
namespace internal {
42+
void *alloc (std::size_t size);
43+
void *realloc (void *n, std::size_t size);
44+
}
4145
template<typename T>
42-
constexpr T *alloc (std::size_t size) {
43-
printf("alloc()\n");
44-
auto p = static_cast<T *> (::malloc(size));
46+
T *alloc (std::size_t size) {
47+
auto p = static_cast<T *> (internal::alloc(size));
4548
if (!p) { throw std::bad_alloc(); }
4649
return p;
4750
}
4851

49-
inline void free (void *p) {
50-
::free(p);
51-
}
52+
void free (void *p);
5253

5354
template<typename T>
54-
constexpr T *realloc (T *n, std::size_t size) {
55-
printf("realloc()\n");
56-
auto p = static_cast<T *> (::realloc(n, size));
55+
T *realloc (T *n, std::size_t size) {
56+
auto p = static_cast<T *> (internal::realloc(n, size));
5757
if (!p) { throw std::bad_alloc(); }
5858
return p;
5959
}

main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ int main () {
117117

118118
router.GET ("/http-test", [cnt = std::make_shared<std::atomic<int>>(0)] (manapi::net::http::request &req, manapi::net::http::response &resp) mutable
119119
-> manapi::future<> {
120-
resp.compress_enabled(false);
121-
co_return resp.text(std::to_string(cnt->fetch_add(1)));
120+
co_return resp.text("");
122121
});
123122

124123
router.GET("/random", [] (manapi::net::http::request &req, manapi::net::http::response &resp) -> manapi::future<> {

src/ManapiUtils.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
#include <mutex>
22
#include <stack>
33

4+
#include "ManapiUtils.hpp"
5+
6+
void manapi::memory::free(void *p) {
7+
::free(p);
8+
}
9+
10+
void *manapi::memory::internal::alloc(std::size_t size) {
11+
return ::malloc(size);
12+
}
13+
14+
void *manapi::memory::internal::realloc(void *n,std::size_t size) {
15+
return ::realloc(n, size);
16+
}
17+

0 commit comments

Comments
 (0)