Skip to content

Commit c8992fc

Browse files
committed
Change return value of 'ecma_ref_ecma_string' to void
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
1 parent 2e03bdc commit c8992fc

17 files changed

+49
-40
lines changed

jerry-core/ecma/base/ecma-helpers-string.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,13 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
384384

385385
if (str1_size == 0)
386386
{
387-
return ecma_ref_ecma_string (string2_p);
387+
ecma_ref_ecma_string (string2_p);
388+
return string2_p;
388389
}
389390
else if (str2_size == 0)
390391
{
391-
return ecma_ref_ecma_string (string1_p);
392+
ecma_ref_ecma_string (string1_p);
393+
return string1_p;
392394
}
393395

394396
const lit_utf8_size_t new_size = str1_size + str2_size;
@@ -444,11 +446,8 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
444446

445447
/**
446448
* Increase reference counter of ecma-string.
447-
*
448-
* @return pointer to same ecma-string descriptor with increased reference counter
449-
* or the ecma-string's copy with reference counter set to 1
450449
*/
451-
ecma_string_t *
450+
void
452451
ecma_ref_ecma_string (ecma_string_t *string_p) /**< string descriptor */
453452
{
454453
JERRY_ASSERT (string_p != NULL);
@@ -463,8 +462,6 @@ ecma_ref_ecma_string (ecma_string_t *string_p) /**< string descriptor */
463462
{
464463
jerry_fatal (ERR_REF_COUNT_LIMIT);
465464
}
466-
467-
return string_p;
468465
} /* ecma_ref_ecma_string */
469466

470467
/**

jerry-core/ecma/base/ecma-helpers-value.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ ecma_copy_value (ecma_value_t value) /**< value description */
637637
}
638638
case ECMA_TYPE_STRING:
639639
{
640-
return ecma_make_string_value (ecma_ref_ecma_string (ecma_get_string_from_value (value)));
640+
ecma_ref_ecma_string (ecma_get_string_from_value (value));
641+
return value;
641642
}
642643
case ECMA_TYPE_OBJECT:
643644
{

jerry-core/ecma/base/ecma-helpers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
584584

585585
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA | prop_attributes;
586586

587-
name_p = ecma_ref_ecma_string (name_p);
587+
ecma_ref_ecma_string (name_p);
588588

589589
ecma_property_value_t value;
590590
value.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
@@ -610,7 +610,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
610610

611611
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR | prop_attributes;
612612

613-
name_p = ecma_ref_ecma_string (name_p);
613+
ecma_ref_ecma_string (name_p);
614614

615615
ecma_property_value_t value;
616616
ECMA_SET_POINTER (value.getter_setter_pair.getter_p, get_p);

jerry-core/ecma/base/ecma-helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern ecma_string_t *ecma_new_ecma_string_from_lit_cp (lit_cpointer_t);
169169
extern ecma_string_t *ecma_new_ecma_string_from_magic_string_id (lit_magic_string_id_t);
170170
extern ecma_string_t *ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t);
171171
extern ecma_string_t *ecma_concat_ecma_strings (ecma_string_t *, ecma_string_t *);
172-
extern ecma_string_t *ecma_ref_ecma_string (ecma_string_t *);
172+
extern void ecma_ref_ecma_string (ecma_string_t *);
173173
extern void ecma_deref_ecma_string (ecma_string_t *);
174174
extern ecma_number_t ecma_string_to_number (const ecma_string_t *);
175175
extern bool ecma_string_get_array_index (const ecma_string_t *, uint32_t *);

jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ ecma_builtin_array_prototype_object_to_locale_string (const ecma_value_t this_ar
175175
ecma_builtin_helper_get_to_locale_string_at_index (obj_p, 0),
176176
ret_value);
177177

178-
ecma_string_t *return_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (first_value));
178+
ecma_string_t *return_string_p = ecma_get_string_from_value (first_value);
179+
ecma_ref_ecma_string (return_string_p);
179180

180181
/* 9-10. */
181182
for (uint32_t k = 1; ecma_is_value_empty (ret_value) && (k < length); k++)
@@ -402,7 +403,8 @@ ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argume
402403
ecma_op_array_get_to_string_at_index (obj_p, 0),
403404
ret_value);
404405

405-
ecma_string_t *return_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (first_value));
406+
ecma_string_t *return_string_p = ecma_get_string_from_value (first_value);
407+
ecma_ref_ecma_string (return_string_p);
406408

407409
/* 9-10. */
408410
for (uint32_t k = 1; ecma_is_value_empty (ret_value) && (k < length); k++)

jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
125125

126126
if (ecma_string_get_length (name_string_p) == 0)
127127
{
128-
ret_str_p = ecma_ref_ecma_string (msg_string_p);
128+
ret_str_p = msg_string_p;
129+
ecma_ref_ecma_string (ret_str_p);
129130
}
130131
else if (ecma_string_get_length (msg_string_p) == 0)
131132
{
132-
ret_str_p = ecma_ref_ecma_string (name_string_p);
133+
ret_str_p = name_string_p;
134+
ecma_ref_ecma_string (ret_str_p);
133135
}
134136
else
135137
{

jerry-core/ecma/builtin-objects/ecma-builtin-json.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,8 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
992992

993993
if (num_of_chars < 10)
994994
{
995-
context.gap_str_p = ecma_ref_ecma_string (space_str_p);
995+
ecma_ref_ecma_string (space_str_p);
996+
context.gap_str_p = space_str_p;
996997
}
997998
else
998999
{
@@ -1061,7 +1062,8 @@ ecma_builtin_json_quote (ecma_string_t *string_p) /**< string that should be quo
10611062
{
10621063
/* 1. */
10631064
ecma_string_t *quote_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_DOUBLE_QUOTE_CHAR);
1064-
ecma_string_t *product_str_p = ecma_ref_ecma_string (quote_str_p);
1065+
ecma_ref_ecma_string (quote_str_p);
1066+
ecma_string_t *product_str_p = quote_str_p;
10651067
ecma_string_t *tmp_str_p;
10661068

10671069
ECMA_STRING_TO_UTF8_STRING (string_p, string_buff, string_buff_size);

jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
168168
}
169169
else
170170
{
171-
pattern_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (regexp_str_value));
171+
pattern_string_p = ecma_get_string_from_value (regexp_str_value);
172+
ecma_ref_ecma_string (pattern_string_p);
172173
}
173174

174175
ECMA_FINALIZE (regexp_str_value);
@@ -380,8 +381,7 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
380381

381382
ecma_string_t *src_sep_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_SLASH_CHAR);
382383
ecma_string_t *source_str_p = ecma_get_string_from_value (ecma_get_named_data_property_value (source_prop_p));
383-
ecma_string_t *output_str_p = ecma_concat_ecma_strings (src_sep_str_p, ecma_ref_ecma_string (source_str_p));
384-
ecma_deref_ecma_string (source_str_p);
384+
ecma_string_t *output_str_p = ecma_concat_ecma_strings (src_sep_str_p, source_str_p);
385385

386386
ecma_string_t *concat_p = ecma_concat_ecma_strings (output_str_p, src_sep_str_p);
387387
ecma_deref_ecma_string (src_sep_str_p);

jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /*
109109
}
110110
else
111111
{
112-
pattern_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (regexp_str_value));
112+
pattern_string_p = ecma_get_string_from_value (regexp_str_value);
113+
ecma_ref_ecma_string (pattern_string_p);
113114
}
114115

115116
ECMA_FINALIZE (regexp_str_value);
@@ -125,7 +126,9 @@ ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /*
125126
ecma_op_to_string (flags_value),
126127
ret_value);
127128

128-
flags_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (flags_str_value));
129+
flags_string_p = ecma_get_string_from_value (flags_str_value);
130+
ecma_ref_ecma_string (flags_string_p);
131+
129132
ECMA_FINALIZE (flags_str_value);
130133
}
131134

jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this_arg) /**< this
7979
ecma_property_t *prim_value_prop_p = ecma_get_internal_property (obj_p,
8080
ECMA_INTERNAL_PROPERTY_ECMA_VALUE);
8181

82-
ecma_string_t *prim_value_str_p;
83-
prim_value_str_p = ecma_get_string_from_value (ecma_get_internal_property_value (prim_value_prop_p));
84-
85-
prim_value_str_p = ecma_ref_ecma_string (prim_value_str_p);
86-
87-
return ecma_make_string_value (prim_value_str_p);
82+
return ecma_copy_value (ecma_get_internal_property_value (prim_value_prop_p));
8883
}
8984
}
9085

@@ -250,10 +245,11 @@ ecma_builtin_string_prototype_object_concat (ecma_value_t this_arg, /**< this ar
250245
ret_value);
251246

252247
/* 3 */
253-
// No copy performed
248+
/* No copy performed */
254249

255250
/* 4 */
256-
ecma_string_t *string_to_return = ecma_ref_ecma_string (ecma_get_string_from_value (to_string_val));
251+
ecma_string_t *string_to_return = ecma_get_string_from_value (to_string_val);
252+
ecma_ref_ecma_string (string_to_return);
257253

258254
/* 5 */
259255
for (uint32_t arg_index = 0;
@@ -659,7 +655,8 @@ ecma_builtin_string_prototype_object_replace_append_substr (ecma_string_t *base_
659655
}
660656
else
661657
{
662-
ret_string_p = ecma_ref_ecma_string (base_string_p);
658+
ret_string_p = base_string_p;
659+
ecma_ref_ecma_string (ret_string_p);
663660
}
664661

665662
return ret_string_p;

0 commit comments

Comments
 (0)