diff options
author | Zoltan Herczeg <zherczeg.u-szeged@partner.samsung.com> | 2021-10-28 13:51:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-28 13:51:34 +0200 |
commit | a024eb2118d69a8e1bcc1e02e4a5ad81610bcffe (patch) | |
tree | db99fa0491ba4ee5d18319ea39e6879bfda75db1 /jerry-core/include/jerryscript-types.h | |
parent | d2388e907f1354455db1045607ee487abf0ce526 (diff) |
Add allocate/free callbacks to ArrayBuffers (#4801)
Larger buffer allocations will throw error instead of calling jerry_fatal.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
Diffstat (limited to 'jerry-core/include/jerryscript-types.h')
-rw-r--r-- | jerry-core/include/jerryscript-types.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/jerry-core/include/jerryscript-types.h b/jerry-core/include/jerryscript-types.h index 87228711..c17876b4 100644 --- a/jerry-core/include/jerryscript-types.h +++ b/jerry-core/include/jerryscript-types.h @@ -819,6 +819,31 @@ typedef struct } jerry_source_info_t; /** + * Array buffer types. + */ + +/** + * Type of an array buffer. + */ +typedef enum +{ + JERRY_ARRAYBUFFER_TYPE_ARRAYBUFFER, /**< the object is an array buffer object */ + JERRY_ARRAYBUFFER_TYPE_SHARED_ARRAYBUFFER, /**< the object is a shared array buffer object */ +} jerry_arraybuffer_type_t; + +/** + * Callback for allocating the backing store of array buffer or shared array buffer objects. + */ +typedef uint8_t *(*jerry_arraybuffer_allocate_t) (jerry_arraybuffer_type_t buffer_type, uint32_t buffer_size, + void **arraybuffer_user_p, void *user_p); + +/** + * Callback for freeing the backing store of array buffer or shared array buffer objects. + */ +typedef void (*jerry_arraybuffer_free_t) (jerry_arraybuffer_type_t buffer_type, uint8_t *buffer_p, + uint32_t buffer_size, void *arraybuffer_user_p, void *user_p); + +/** * @} */ |