Commit 29ff1449 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added jsstr_flush helper and use it in array_join.

parent 0effd926
......@@ -286,15 +286,10 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
if(SUCCEEDED(hres))
ret = jsstr_alloc_buf(len);
if(ret) {
unsigned tmplen;
ptr = ret->str;
if(str_tab[0]) {
tmplen = jsstr_length(str_tab[0]);
memcpy(ptr, str_tab[0]->str, tmplen*sizeof(WCHAR));
ptr += tmplen;
}
if(str_tab[0])
ptr += jsstr_flush(str_tab[0], ptr);
for(i=1; i < length; i++) {
if(seplen) {
......@@ -302,13 +297,9 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
ptr += seplen;
}
if(str_tab[i]) {
tmplen = jsstr_length(str_tab[i]);
memcpy(ptr, str_tab[i]->str, tmplen*sizeof(WCHAR));
ptr += tmplen;
}
if(str_tab[i])
ptr += jsstr_flush(str_tab[i], ptr);
}
*ptr=0;
}else {
hres = E_OUTOFMEMORY;
}
......
......@@ -59,6 +59,13 @@ static inline BOOL jsstr_eq(jsstr_t *str1, jsstr_t *str2)
return len == jsstr_length(str2) && !memcmp(str1->str, str2->str, len*sizeof(WCHAR));
}
static inline unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
{
unsigned len = jsstr_length(str);
memcpy(buf, str->str, len*sizeof(WCHAR));
return len;
}
static inline jsstr_t *jsstr_substr(jsstr_t *str, unsigned off, unsigned len)
{
return jsstr_alloc_len(str->str+off, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment