Welcome! Log In Create A New Profile

Advanced

[njs] Added njs_is_memory_error() function.

Alexander Borisov
December 03, 2019 10:16AM
details: https://hg.nginx.org/njs/rev/ef64784b77f6
branches:
changeset: 1277:ef64784b77f6
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Tue Dec 03 18:02:40 2019 +0300
description:
Added njs_is_memory_error() function.

diffstat:

src/njs_error.h | 14 ++++++++++++++
src/njs_vm.c | 7 +------
2 files changed, 15 insertions(+), 6 deletions(-)

diffs (39 lines):

diff -r 6e84ff419b88 -r ef64784b77f6 src/njs_error.h
--- a/src/njs_error.h Tue Dec 03 17:58:30 2019 +0300
+++ b/src/njs_error.h Tue Dec 03 18:02:40 2019 +0300
@@ -59,4 +59,18 @@ extern const njs_object_type_init_t njs
extern const njs_object_type_init_t njs_memory_error_type_init;


+njs_inline njs_int_t
+njs_is_memory_error(njs_vm_t *vm, njs_value_t *value)
+{
+ if (njs_is_error(value)
+ && njs_has_prototype(vm, value, NJS_OBJ_TYPE_INTERNAL_ERROR)
+ && !njs_object(value)->extensible)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+
#endif /* _NJS_BOOLEAN_H_INCLUDED_ */
diff -r 6e84ff419b88 -r ef64784b77f6 src/njs_vm.c
--- a/src/njs_vm.c Tue Dec 03 17:58:30 2019 +0300
+++ b/src/njs_vm.c Tue Dec 03 18:02:40 2019 +0300
@@ -852,12 +852,7 @@ njs_vm_value_to_string(njs_vm_t *vm, njs
}

if (njs_is_error(src)) {
-
- /* MemoryError is a nonextensible internal error. */
-
- if (njs_has_prototype(vm, src, NJS_OBJ_TYPE_INTERNAL_ERROR)
- && !njs_object(src)->extensible)
- {
+ if (njs_is_memory_error(vm, src)) {
njs_string_get(&njs_string_memory_error, dst);
return NJS_OK;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Added njs_is_memory_error() function.

Alexander Borisov 82 December 03, 2019 10:16AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 81
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready