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
|
||||
|
||||
@@ -96,37 +96,6 @@ typedef bool (*jerry_debugger_transport_receive_t) (struct jerry_debugger_transp
|
||||
|
||||
# Transport interface API functions
|
||||
|
||||
## jerry_debugger_transport_malloc
|
||||
|
||||
**Summary**
|
||||
|
||||
Allocates memory for the transport interface.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void * jerry_debugger_transport_malloc (size_t size);
|
||||
```
|
||||
|
||||
- `size`: size of the memory block.
|
||||
- return value: non-NULL pointer, if the memory is successfully allocated,
|
||||
NULL otherwise.
|
||||
|
||||
## jerry_debugger_transport_free
|
||||
|
||||
**Summary**
|
||||
|
||||
Free memory allocated by [jerry_debugger_transport_malloc](#jerry_debugger_transport_malloc)
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_debugger_transport_free (void *mem_p, size_t size);
|
||||
```
|
||||
|
||||
- `header_p`: header of a transporation interface.
|
||||
- `size`: total size of the transportation interface.
|
||||
|
||||
## jerry_debugger_transport_add
|
||||
|
||||
**Summary**
|
||||
@@ -180,7 +149,7 @@ bool jerry_debugger_transport_is_connected (void);
|
||||
**Summary**
|
||||
|
||||
Disconnect from the current debugger client. It does nothing if a client is
|
||||
not connected,
|
||||
not connected.
|
||||
|
||||
**Prototype**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user