-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathContext.cpp
More file actions
38 lines (32 loc) · 881 Bytes
/
Copy pathContext.cpp
File metadata and controls
38 lines (32 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/****
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
* Created 2015 by Skurydin Alexey
* http://github.com/SmingHub/Sming
* All files of the Sming Core are provided under the LGPL v3 license.
*
* Context.cpp
*
* @author: Dec 2021 - Mikee47 <mike@sillyhouse.net>
*
*/
#include "include/Jerryscript/Context.h"
namespace Jerryscript
{
Context* Context::current;
Context::Context() : Context(JERRY_GLOBAL_HEAP_SIZE * 1024)
{
}
Context::Context(size_t heapSize)
{
context = std::make_unique<uint8_t[]>(std::max(heapSize, size_t(1024U)));
}
void* Context::alloc(size_t size, void* param)
{
// Store user parameter (this pointer) after jerryscript context
auto buf = new uint8_t[size + sizeof(param)];
if(buf != nullptr) {
*reinterpret_cast<void**>(buf + size) = param;
}
return buf;
}
} // namespace Jerryscript