ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length, /**< length of the buffer */
                                       lit_utf8_size_t size, /**< size of the buffer */
                                       lit_utf8_byte_t **data_p) /**< [out] pointer to the start of the string buffer */
{
  if (JERRY_LIKELY (size <= UINT16_MAX))
  {
    if (JERRY_LIKELY (length == size) && size <= (UINT8_MAX + 1))
    {
      ecma_string_t *string_desc_p;
      string_desc_p = (ecma_string_t *) ecma_alloc_string_buffer (size + ECMA_ASCII_STRING_HEADER_SIZE);
      string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_HEAP_ASCII_STRING | ECMA_STRING_REF_ONE;
      ECMA_ASCII_STRING_SET_SIZE (string_desc_p, size);

      *data_p = ECMA_ASCII_STRING_GET_BUFFER (string_desc_p);
      return (ecma_string_t *) string_desc_p;
    }

    ecma_short_string_t *string_desc_p;
    string_desc_p = (ecma_short_string_t *) ecma_alloc_string_buffer (size + sizeof (ecma_short_string_t));
    string_desc_p->header.refs_and_container = ECMA_STRING_CONTAINER_HEAP_UTF8_STRING | ECMA_STRING_REF_ONE;
    string_desc_p->size = (uint16_t) size;
    string_desc_p->length = (uint16_t) length;

    *data_p = ECMA_SHORT_STRING_GET_BUFFER (string_desc_p);
    return (ecma_string_t *) string_desc_p;
  }

  ecma_long_string_t *long_string_p;
  long_string_p = (ecma_long_string_t *) ecma_alloc_string_buffer (size + sizeof (ecma_long_string_t));
  long_string_p->header.refs_and_container = ECMA_STRING_CONTAINER_LONG_OR_EXTERNAL_STRING | ECMA_STRING_REF_ONE;
  long_string_p->string_p = ECMA_LONG_STRING_BUFFER_START (long_string_p);
  long_string_p->size = size;
  long_string_p->length = length;

  *data_p = ECMA_LONG_STRING_BUFFER_START (long_string_p);
  return (ecma_string_t *) long_string_p;
} /* ecma_new_ecma_string_from_utf8_buffer */
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length,  
                                       lit_utf8_size_t size,  
                                       lit_utf8_byte_t **data_p)  
{
  if (JERRY_LIKELY (size <= UINT16_MAX))
  {
    if (JERRY_LIKELY (length == size) && size <= (UINT8_MAX + 1))
    {
      ecma_string_t *string_desc_p;
      string_desc_p = (ecma_string_t *) ecma_alloc_string_buffer (size + ECMA_ASCII_STRING_HEADER_SIZE);
      string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_HEAP_ASCII_STRING | ECMA_STRING_REF_ONE;
      ECMA_ASCII_STRING_SET_SIZE (string_desc_p, size);

      *data_p = ECMA_ASCII_STRING_GET_BUFFER (string_desc_p);
      return (ecma_string_t *) string_desc_p;
    }

    ecma_short_string_t *string_desc_p;
    string_desc_p = (ecma_short_string_t *) ecma_alloc_string_buffer (size + sizeof (ecma_short_string_t));
    string_desc_p->header.refs_and_container = ECMA_STRING_CONTAINER_HEAP_UTF8_STRING | ECMA_STRING_REF_ONE;
    string_desc_p->size = (uint16_t) size;
    string_desc_p->length = (uint16_t) length;

    *data_p = ECMA_SHORT_STRING_GET_BUFFER (string_desc_p);
    return (ecma_string_t *) string_desc_p;
  }

  ecma_long_string_t *long_string_p;
  long_string_p = (ecma_long_string_t *) ecma_alloc_string_buffer (size + sizeof (ecma_long_string_t));
  long_string_p->header.refs_and_container = ECMA_STRING_CONTAINER_LONG_OR_EXTERNAL_STRING | ECMA_STRING_REF_ONE;
  long_string_p->string_p = ECMA_LONG_STRING_BUFFER_START (long_string_p);
  long_string_p->size = size;
  long_string_p->length = length;

  *data_p = ECMA_LONG_STRING_BUFFER_START (long_string_p);
  return (ecma_string_t *) long_string_p;
}  