From 11d5402c352a85f6315f22908a4dadcd25c18981 Mon Sep 17 00:00:00 2001 From: Zidong Jiang Date: Mon, 5 Jun 2017 03:44:56 -0500 Subject: [PATCH] Allow out_native_pointer_p in jerry_get_object_native_pointer to be NULL (#1876) Support those cases when the existence of the native property is checked. JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com --- docs/02.API-REFERENCE.md | 3 +++ jerry-core/api/jerry.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/02.API-REFERENCE.md b/docs/02.API-REFERENCE.md index 57934eacb..5edc21075 100644 --- a/docs/02.API-REFERENCE.md +++ b/docs/02.API-REFERENCE.md @@ -3629,6 +3629,9 @@ The pointer and the type information are previously associated with the object b `out_native_pointer_p` is of the expected type, before casting and dereferencing `out_native_pointer_p`. +*Note*: `out_native_pointer_p` and `out_native_info_p` can be NULL, and it means the + caller doesn't want to get the native_pointer or type infomation. + **Prototype** ```c diff --git a/jerry-core/api/jerry.c b/jerry-core/api/jerry.c index 466797289..5c69b6510 100644 --- a/jerry-core/api/jerry.c +++ b/jerry-core/api/jerry.c @@ -2100,9 +2100,12 @@ jerry_get_object_native_pointer (const jerry_value_t obj_val, /**< object to get return false; } - *out_native_pointer_p = native_pointer_p->data_p; + if (out_native_pointer_p != NULL) + { + *out_native_pointer_p = native_pointer_p->data_p; + } - if (out_native_info_p) + if (out_native_info_p != NULL) { *out_native_info_p = (const jerry_object_native_info_t *) native_pointer_p->u.info_p; }