Promote dynamic memory management from debugger transport to core API (#2503)
Under the cover of the debugger transport layer, allocation on the engine's heap has been made available to the public. As there are actually no restrictions on what the allocated memory can be used for, the memory management functions better fit in the core part of the API. Closes #1805 JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -4875,6 +4875,52 @@ main (void)
|
||||
- [jerry_substring_to_char_buffer](#jerry_substring_to_char_buffer)
|
||||
|
||||
|
||||
# Dynamic memory management functions
|
||||
|
||||
## jerry_heap_alloc
|
||||
|
||||
**Summary**
|
||||
|
||||
Allocate memory on the engine's heap.
|
||||
|
||||
*Note*: This function may take away memory from the executed JavaScript code.
|
||||
If any other dynamic memory allocation API is available (e.g., libc malloc), it
|
||||
should be used instead.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void *jerry_heap_alloc (size_t size);
|
||||
```
|
||||
|
||||
- `size`: size of the memory block.
|
||||
- return value: non-NULL pointer, if the memory is successfully allocated,
|
||||
NULL otherwise.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_heap_free](#jerry_heap_free)
|
||||
|
||||
## jerry_heap_free
|
||||
|
||||
**Summary**
|
||||
|
||||
Free memory allocated on the engine's heap.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_heap_free (void *mem_p, size_t size);
|
||||
```
|
||||
|
||||
- `mem_p`: value returned by `jerry_heap_alloc`.
|
||||
- `size`: same size as passed to `jerry_heap_alloc`.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_heap_alloc](#jerry_heap_alloc)
|
||||
|
||||
|
||||
# External context functions
|
||||
|
||||
## jerry_create_context
|
||||
|
||||
Reference in New Issue
Block a user