Update the webpage (#1542)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
This commit is contained in:
committed by
László Langó
parent
dd84f11996
commit
b89c74fd39
+13
-11
@@ -20,7 +20,7 @@ by `jerry_release_value`.
|
||||
/* The value stored in the 'global' variable contains a live
|
||||
* reference to the global object. The system also keeps its
|
||||
* own live reference to the global object. These two references
|
||||
* are indepent, and both must be destroyed before the global
|
||||
* are independent, and both must be destroyed before the global
|
||||
* object can be freed. */
|
||||
|
||||
jerry_release_value (global);
|
||||
@@ -57,16 +57,17 @@ following code is an **INCORRECT WAY** of releasing the 3.14 value.
|
||||
|
||||
JerryScript API functions returning with a `jerry_value_t` always
|
||||
return with a new live reference. Passing a `jerry_value_t` to
|
||||
an API function never releases its reference. The next example
|
||||
shows this behaviour through property getting and setting.
|
||||
an API function never releases its reference (unless explicitly
|
||||
stated in the documentation). The next example shows this
|
||||
behaviour through property getting and setting.
|
||||
|
||||
```c
|
||||
jerry_value_t prop_value = jerry_get_property (...);
|
||||
|
||||
/* The prop_value must be released later because both the base
|
||||
* object and the prop_value have an independent reference to
|
||||
* the same JavaScript value. When the operation is failed
|
||||
* the prop_value contains a live reference to an error object.
|
||||
* the same JavaScript value. When the operation fails, the
|
||||
* prop_value contains a live reference to an error object.
|
||||
* This reference must be released as well. */
|
||||
|
||||
if (jerry_value_has_error_flag (prop_value))
|
||||
@@ -85,20 +86,21 @@ shows this behaviour through property getting and setting.
|
||||
|
||||
/* Property setting is the same. */
|
||||
|
||||
jerry_value_t new_prop_value = jerry_create_number (2.718);
|
||||
jerry_value_t result = jerry_set_property (..., new_prop_value);
|
||||
|
||||
/* If the property set is successful a new reference is created
|
||||
/* If the property set is successful, a new reference is created
|
||||
* for the value referenced by new_prop_value. The new_prop_value
|
||||
* reference must be released regardless the operation is
|
||||
* successful. */
|
||||
* reference must be released regardless of whether the operation
|
||||
* is successful. */
|
||||
|
||||
/* The new_prop_value can be passed to other JerryScript API
|
||||
* functions before the jerry_release_value () call. */
|
||||
|
||||
jerry_release_value (new_prop_value);
|
||||
|
||||
/* The reference stored in 'result' variable contains whether
|
||||
* the operation is successful and must also be freed. */
|
||||
/* The reference stored in the 'result' variable is live whether
|
||||
* the operation is successful or not, and must also be freed. */
|
||||
|
||||
if (jerry_value_has_error_flag (result))
|
||||
{
|
||||
@@ -179,5 +181,5 @@ References can be duplicated in C as long as only one of them is freed.
|
||||
jerry_release_value (c);
|
||||
/* Both 'b' and 'c' (boolean true) references become dead. */
|
||||
|
||||
/* Since all references are released no memory leak is possible. */
|
||||
/* Since all references are released, no memory leak occurs. */
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user