[njs] Added njs_vm_value_array_buffer_set().
Dmitry Volyntsev
xeioex at nginx.com
Mon Jan 11 19:53:58 UTC 2021
details: https://hg.nginx.org/njs/rev/59ab52c9700b
branches:
changeset: 1588:59ab52c9700b
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Jan 11 19:53:08 2021 +0000
description:
Added njs_vm_value_array_buffer_set().
diffstat:
src/njs.h | 3 +++
src/njs_vm.c | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diffs (43 lines):
diff -r d7ef83814374 -r 59ab52c9700b src/njs.h
--- a/src/njs.h Mon Jan 11 19:53:05 2021 +0000
+++ b/src/njs.h Mon Jan 11 19:53:08 2021 +0000
@@ -331,6 +331,9 @@ NJS_EXPORT u_char *njs_vm_value_string_a
NJS_EXPORT njs_int_t njs_vm_value_string_copy(njs_vm_t *vm, njs_str_t *retval,
njs_value_t *value, uintptr_t *next);
+NJS_EXPORT njs_int_t njs_vm_value_array_buffer_set(njs_vm_t *vm,
+ njs_value_t *value, const u_char *start, uint32_t size);
+
/*
* Sets a Buffer value.
* start data is not copied and should not be freed.
diff -r d7ef83814374 -r 59ab52c9700b src/njs_vm.c
--- a/src/njs_vm.c Mon Jan 11 19:53:05 2021 +0000
+++ b/src/njs_vm.c Mon Jan 11 19:53:08 2021 +0000
@@ -733,6 +733,26 @@ njs_vm_value_string_set(njs_vm_t *vm, nj
njs_int_t
+njs_vm_value_array_buffer_set(njs_vm_t *vm, njs_value_t *value,
+ const u_char *start, uint32_t size)
+{
+ njs_array_buffer_t *array;
+
+ array = njs_array_buffer_alloc(vm, 0, 0);
+ if (njs_slow_path(array == NULL)) {
+ return NJS_ERROR;
+ }
+
+ array->u.data = (u_char *) start;
+ array->size = size;
+
+ njs_set_array_buffer(value, array);
+
+ return NJS_OK;
+}
+
+
+njs_int_t
njs_vm_value_buffer_set(njs_vm_t *vm, njs_value_t *value, const u_char *start,
uint32_t size)
{
More information about the nginx-devel
mailing list