Commit 4ece40f8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Return buffer pointer separately from jsstr_t from jsstr_alloc_len.

parent 79632a22
......@@ -234,7 +234,7 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, jsval_t *r)
{
jsstr_t **str_tab, *ret = NULL;
jsstr_t **str_tab, *ret;
jsval_t val;
DWORD i;
HRESULT hres = E_FAIL;
......@@ -267,7 +267,6 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
if(SUCCEEDED(hres)) {
DWORD seplen = 0, len = 0;
WCHAR *ptr;
seplen = strlenW(sep);
......@@ -283,11 +282,11 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
}
}
if(SUCCEEDED(hres))
ret = jsstr_alloc_buf(len);
if(ret) {
ptr = ret->str;
if(SUCCEEDED(hres)) {
WCHAR *ptr = NULL;
ptr = jsstr_alloc_buf(len, &ret);
if(ptr) {
if(str_tab[0])
ptr += jsstr_flush(str_tab[0], ptr);
......@@ -304,6 +303,7 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
hres = E_OUTOFMEMORY;
}
}
}
for(i=0; i < length; i++) {
if(str_tab[i])
......
......@@ -492,7 +492,7 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
BOOL formatAD = TRUE;
WCHAR week[64], month[64];
jsstr_t *date_str;
jsstr_t *date_jsstr;
int len, size, year, day;
DWORD lcid_en;
WCHAR sign = '-';
......@@ -504,6 +504,8 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
}
if(r) {
WCHAR *date_str;
len = 21;
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
......@@ -544,25 +546,25 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
offset = -offset;
}
date_str = jsstr_alloc_buf(len);
date_str = jsstr_alloc_buf(len, &date_jsstr);
if(!date_str)
return E_OUTOFMEMORY;
if(!show_offset)
sprintfW(date_str->str, formatNoOffsetW, week, month, day,
sprintfW(date_str, formatNoOffsetW, week, month, day,
(int)hour_from_time(time), (int)min_from_time(time),
(int)sec_from_time(time), year, formatAD?ADW:BCW);
else if(offset)
sprintfW(date_str->str, formatW, week, month, day,
sprintfW(date_str, formatW, week, month, day,
(int)hour_from_time(time), (int)min_from_time(time),
(int)sec_from_time(time), sign, offset/60, offset%60,
year, formatAD?ADW:BCW);
else
sprintfW(date_str->str, formatUTCW, week, month, day,
sprintfW(date_str, formatUTCW, week, month, day,
(int)hour_from_time(time), (int)min_from_time(time),
(int)sec_from_time(time), year, formatAD?ADW:BCW);
*r = jsval_string(date_str);
*r = jsval_string(date_jsstr);
}
return S_OK;
}
......@@ -618,14 +620,18 @@ static HRESULT Date_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return dateobj_to_string(date, r);
if(r) {
WCHAR *ptr;
date_len = GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, NULL, 0);
time_len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0);
date_str = jsstr_alloc_buf(date_len+time_len-1);
ptr = jsstr_alloc_buf(date_len+time_len-1, &date_str);
if(!date_str)
return E_OUTOFMEMORY;
GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, date_str->str, date_len);
GetTimeFormatW(ctx->lcid, 0, &st, NULL, date_str->str+date_len, time_len);
date_str->str[date_len-1] = ' ';
GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, ptr, date_len);
GetTimeFormatW(ctx->lcid, 0, &st, NULL, ptr+date_len, time_len);
ptr[date_len-1] = ' ';
*r = jsval_string(date_str);
}
......@@ -681,6 +687,8 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva
}
if(r) {
WCHAR *ptr;
len = 17;
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
......@@ -713,11 +721,11 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva
} while(day);
day = date_from_time(date->time);
date_str = jsstr_alloc_buf(len);
ptr = jsstr_alloc_buf(len, &date_str);
if(!date_str)
return E_OUTOFMEMORY;
sprintfW(date_str->str, formatAD?formatADW:formatBCW, week, day, month, year,
sprintfW(ptr, formatAD?formatADW:formatBCW, week, day, month, year,
(int)hour_from_time(date->time), (int)min_from_time(date->time),
(int)sec_from_time(date->time));
......@@ -773,6 +781,8 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r)
time = local_time(date->time, date);
if(r) {
WCHAR *ptr;
len = 5;
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
......@@ -807,10 +817,10 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r)
} while(day);
day = date_from_time(time);
date_str = jsstr_alloc_buf(len);
if(!date_str)
ptr = jsstr_alloc_buf(len, &date_str);
if(!ptr)
return E_OUTOFMEMORY;
sprintfW(date_str->str, formatAD?formatADW:formatBCW, week, month, day, year);
sprintfW(ptr, formatAD?formatADW:formatBCW, week, month, day, year);
*r = jsval_string(date_str);
}
......@@ -856,7 +866,9 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
time = local_time(date->time, date);
if(r) {
date_str = jsstr_alloc_buf(17);
WCHAR *ptr;
ptr = jsstr_alloc_buf(17, &date_str);
if(!date_str)
return E_OUTOFMEMORY;
......@@ -870,11 +882,11 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
else sign = '-';
if(offset)
sprintfW(date_str->str, formatW, (int)hour_from_time(time),
sprintfW(ptr, formatW, (int)hour_from_time(time),
(int)min_from_time(time), (int)sec_from_time(time),
sign, offset/60, offset%60);
else
sprintfW(date_str->str, formatUTCW, (int)hour_from_time(time),
sprintfW(ptr, formatUTCW, (int)hour_from_time(time),
(int)min_from_time(time), (int)sec_from_time(time));
*r = jsval_string(date_str);
......@@ -908,11 +920,13 @@ static HRESULT Date_toLocaleDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
return dateobj_to_date_string(date, r);
if(r) {
WCHAR *ptr;
len = GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, NULL, 0);
date_str = jsstr_alloc_buf(len);
if(!date_str)
ptr = jsstr_alloc_buf(len, &date_str);
if(!ptr)
return E_OUTOFMEMORY;
GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, date_str->str, len);
GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, ptr, len);
*r = jsval_string(date_str);
}
......@@ -945,11 +959,13 @@ static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
return Date_toTimeString(ctx, jsthis, flags, argc, argv, r);
if(r) {
WCHAR *ptr;
len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0);
date_str = jsstr_alloc_buf(len);
if(!date_str)
ptr = jsstr_alloc_buf(len, &date_str);
if(!ptr)
return E_OUTOFMEMORY;
GetTimeFormatW(ctx->lcid, 0, &st, NULL, date_str->str, len);
GetTimeFormatW(ctx->lcid, 0, &st, NULL, ptr, len);
*r = jsval_string(date_str);
}
......
......@@ -2001,11 +2001,11 @@ static HRESULT interp_eq2(exec_ctx_t *ctx)
BOOL b;
HRESULT hres;
TRACE("\n");
r = stack_pop(ctx);
l = stack_pop(ctx);
TRACE("%s === %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = equal2_values(r, l, &b);
jsval_release(l);
jsval_release(r);
......
......@@ -83,12 +83,16 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
unsigned msg_len = msg ? jsstr_length(msg) : 0;
if(name_len && msg_len) {
ret = jsstr_alloc_buf(name_len + msg_len + 2);
if(ret) {
jsstr_flush(name, ret->str);
ret->str[name_len] = ':';
ret->str[name_len+1] = ' ';
jsstr_flush(msg, ret->str+name_len+2);
WCHAR *ptr;
ptr = jsstr_alloc_buf(name_len + msg_len + 2, &ret);
if(ptr) {
jsstr_flush(name, ptr);
ptr[name_len] = ':';
ptr[name_len+1] = ' ';
jsstr_flush(msg, ptr+name_len+2);
}else {
hres = E_OUTOFMEMORY;
}
}else if(name_len) {
ret = name;
......
......@@ -318,15 +318,16 @@ static HRESULT function_to_string(FunctionInstance *function, jsstr_t **ret)
if(function->value_proc) {
DWORD name_len;
WCHAR *ptr;
name_len = strlenW(function->name);
str = jsstr_alloc_buf((sizeof(native_prefixW)+sizeof(native_suffixW))/sizeof(WCHAR) + name_len);
if(!str)
ptr = jsstr_alloc_buf((sizeof(native_prefixW)+sizeof(native_suffixW))/sizeof(WCHAR) + name_len, &str);
if(!ptr)
return E_OUTOFMEMORY;
memcpy(str->str, native_prefixW, sizeof(native_prefixW));
memcpy(str->str + sizeof(native_prefixW)/sizeof(WCHAR), function->name, name_len*sizeof(WCHAR));
memcpy(str->str + sizeof(native_prefixW)/sizeof(WCHAR) + name_len, native_suffixW, sizeof(native_suffixW));
memcpy(ptr, native_prefixW, sizeof(native_prefixW));
memcpy(ptr += sizeof(native_prefixW)/sizeof(WCHAR), function->name, name_len*sizeof(WCHAR));
memcpy(ptr + name_len, native_suffixW, sizeof(native_suffixW));
}else {
str = jsstr_alloc_len(function->func_code->source, function->func_code->source_len);
if(!str)
......
......@@ -304,14 +304,13 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
len += 3;
}
ret_str = jsstr_alloc_buf(len);
if(!ret_str) {
ret = jsstr_alloc_buf(len, &ret_str);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
len = 0;
ret = ret_str->str;
for(ptr = str->str; *ptr; ptr++) {
if(*ptr > 0xff) {
ret[len++] = '%';
......@@ -655,13 +654,12 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
len++;
}
ret_str = jsstr_alloc_buf(len);
if(!ret_str) {
ret = jsstr_alloc_buf(len, &ret_str);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
ret = ret_str->str;
len = 0;
for(ptr = str->str; *ptr; ptr++) {
if(*ptr == '%') {
......@@ -793,12 +791,11 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
}
}
ret = jsstr_alloc_buf(len);
if(!ret) {
rptr = jsstr_alloc_buf(len, &ret);
if(!rptr) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
rptr = ret->str;
for(ptr = str->str; *ptr; ptr++) {
if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
......@@ -826,9 +823,10 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r)
{
jsstr_t *str, *ret;
WCHAR *ptr;
int i, len = 0, val, res;
jsstr_t *str, *ret_str;
unsigned len = 0;
WCHAR *ptr, *ret;
int i, val, res;
char buf[4];
WCHAR out;
HRESULT hres;
......@@ -871,17 +869,15 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
}
}
ret = jsstr_alloc_buf(len);
ret = jsstr_alloc_buf(len, &ret_str);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
len = 0;
for(ptr = str->str; *ptr; ptr++) {
if(*ptr != '%') {
ret->str[len] = *ptr;
len++;
*ret++ = *ptr;
}else {
for(i=0; i<4; i++) {
if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
......@@ -889,33 +885,34 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
val += hex_to_int(ptr[i*3+1])<<4;
buf[i] = val;
res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, ret->str+len, 1);
res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, ret, 1);
if(res)
break;
}
ptr += i*3+2;
len++;
ret++;
}
}
TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret));
TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret_str));
jsstr_release(str);
if(r)
*r = jsval_string(ret);
*r = jsval_string(ret_str);
else
jsstr_release(ret);
jsstr_release(ret_str);
return S_OK;
}
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r)
{
jsstr_t *str, *ret;
jsstr_t *str, *ret_str;
char buf[4];
const WCHAR *ptr;
DWORD len = 0, size, i;
WCHAR *ret;
HRESULT hres;
TRACE("\n");
......@@ -943,22 +940,21 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
}
}
ret = jsstr_alloc_buf(len);
ret = jsstr_alloc_buf(len, &ret_str);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
len = 0;
for(ptr = str->str; *ptr; ptr++) {
if(is_uri_unescaped(*ptr)) {
ret->str[len++] = *ptr;
*ret++ = *ptr;
}else {
size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL);
for(i=0; i<size; i++) {
ret->str[len++] = '%';
ret->str[len++] = int_to_char((BYTE)buf[i] >> 4);
ret->str[len++] = int_to_char(buf[i] & 0x0f);
*ret++ = '%';
*ret++ = int_to_char((BYTE)buf[i] >> 4);
*ret++ = int_to_char(buf[i] & 0x0f);
}
}
}
......@@ -966,9 +962,9 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
jsstr_release(str);
if(r)
*r = jsval_string(ret);
*r = jsval_string(ret_str);
else
jsstr_release(ret);
jsstr_release(ret_str);
return S_OK;
}
......@@ -1044,12 +1040,11 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
}
}
ret = jsstr_alloc_buf(len);
out_ptr = jsstr_alloc_buf(len, &ret);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
out_ptr = ret->str;
ptr = str->str;
while(*ptr) {
......
......@@ -25,7 +25,7 @@ const char *debugstr_jsstr(jsstr_t *str)
return debugstr_wn(str->str, jsstr_length(str));
}
jsstr_t *jsstr_alloc_buf(unsigned len)
WCHAR *jsstr_alloc_buf(unsigned len, jsstr_t **r)
{
jsstr_t *ret;
......@@ -39,16 +39,18 @@ jsstr_t *jsstr_alloc_buf(unsigned len)
ret->length_flags = len << JSSTR_LENGTH_SHIFT;
ret->ref = 1;
ret->str[len] = 0;
return ret;
*r = ret;
return ret->str;
}
jsstr_t *jsstr_alloc_len(const WCHAR *buf, unsigned len)
{
jsstr_t *ret;
WCHAR *ptr;
ret = jsstr_alloc_buf(len);
if(ret)
memcpy(ret->str, buf, len*sizeof(WCHAR));
ptr = jsstr_alloc_buf(len, &ret);
if(ptr)
memcpy(ptr, buf, len*sizeof(WCHAR));
return ret;
}
......@@ -70,6 +72,7 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
{
unsigned len1, len2;
jsstr_t *ret;
WCHAR *ptr;
len1 = jsstr_length(str1);
if(!len1)
......@@ -79,12 +82,12 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
if(!len2)
return jsstr_addref(str1);
ret = jsstr_alloc_buf(len1+len2);
ptr = jsstr_alloc_buf(len1+len2, &ret);
if(!ret)
return NULL;
jsstr_flush(str1, ret->str);
jsstr_flush(str2, ret->str+len1);
jsstr_flush(str1, ptr);
jsstr_flush(str2, ptr+len1);
return ret;
}
......@@ -110,7 +113,7 @@ BOOL init_strings(void)
static const WCHAR NaNW[] = { 'N','a','N',0 };
static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
if(!(empty_str = jsstr_alloc_buf(0)))
if(!jsstr_alloc_buf(0, &empty_str))
return FALSE;
if(!(nan_str = jsstr_alloc(NaNW)))
return FALSE;
......
......@@ -34,7 +34,7 @@ static inline unsigned jsstr_length(jsstr_t *str)
}
jsstr_t *jsstr_alloc_len(const WCHAR*,unsigned) DECLSPEC_HIDDEN;
jsstr_t *jsstr_alloc_buf(unsigned) DECLSPEC_HIDDEN;
WCHAR *jsstr_alloc_buf(unsigned,jsstr_t**) DECLSPEC_HIDDEN;
static inline jsstr_t *jsstr_alloc(const WCHAR *str)
{
......
......@@ -125,11 +125,10 @@ static inline jsstr_t *number_to_fixed(double val, int prec)
if(prec)
size += prec+1;
ret = jsstr_alloc_buf(size);
str = jsstr_alloc_buf(size, &ret);
if(!ret)
return NULL;
str = ret->str;
size = buf_pos = 0;
if(neg)
str[size++] = '-';
......@@ -193,11 +192,10 @@ static inline jsstr_t *number_to_exponential(double val, int prec)
if(neg)
size++;
ret = jsstr_alloc_buf(size);
str = jsstr_alloc_buf(size, &ret);
if(!ret)
return NULL;
str = ret->str;
size = 0;
pbuf = buf;
if(neg)
......
......@@ -71,12 +71,13 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
if(r) {
jsstr_t *ret;
WCHAR *ptr;
ret = jsstr_alloc_buf(9+strlenW(str));
if(!ret)
ptr = jsstr_alloc_buf(9+strlenW(str), &ret);
if(!ptr)
return E_OUTOFMEMORY;
sprintfW(ret->str, formatW, str);
sprintfW(ptr, formatW, str);
*r = jsval_string(ret);
}
......
......@@ -160,13 +160,12 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j
tagname_len = strlenW(tagname);
ret = jsstr_alloc_buf(jsstr_length(str) + 2*tagname_len + 5);
ptr = jsstr_alloc_buf(jsstr_length(str) + 2*tagname_len + 5, &ret);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
ptr = ret->str;
*ptr++ = '<';
memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
ptr += tagname_len;
......@@ -209,11 +208,10 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
unsigned attrname_len = strlenW(attrname);
unsigned tagname_len = strlenW(tagname);
jsstr_t *ret;
WCHAR *ptr;
ret = jsstr_alloc_buf(2*tagname_len + attrname_len + jsstr_length(attr_value) + jsstr_length(str) + 9);
if(ret) {
WCHAR *ptr = ret->str;
ptr = jsstr_alloc_buf(2*tagname_len + attrname_len + jsstr_length(attr_value) + jsstr_length(str) + 9, &ret);
if(ptr) {
*ptr++ = '<';
memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
ptr += tagname_len;
......@@ -390,9 +388,8 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
}
}
ret = jsstr_alloc_buf(len);
if(ret) {
ptr = ret->str;
ptr = jsstr_alloc_buf(len, &ret);
if(ptr) {
for(i=0; i < str_cnt; i++)
ptr += jsstr_flush(strs[i], ptr);
}else {
......@@ -1337,15 +1334,16 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(r) {
jsstr_t *ret;
WCHAR *buf;
ret = jsstr_alloc_buf(jsstr_length(str));
if(!ret) {
buf = jsstr_alloc_buf(jsstr_length(str), &ret);
if(!buf) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
jsstr_flush(str, ret->str);
strlwrW(ret->str);
jsstr_flush(str, buf);
strlwrW(buf);
*r = jsval_string(ret);
}
jsstr_release(str);
......@@ -1366,15 +1364,16 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(r) {
jsstr_t *ret;
WCHAR *buf;
ret = jsstr_alloc_buf(jsstr_length(str));
if(!ret) {
buf = jsstr_alloc_buf(jsstr_length(str), &ret);
if(!buf) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
jsstr_flush(str, ret->str);
struprW(ret->str);
jsstr_flush(str, buf);
struprW(buf);
*r = jsval_string(ret);
}
jsstr_release(str);
......@@ -1525,14 +1524,15 @@ static const builtin_info_t StringInst_info = {
static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r)
{
WCHAR *ret_str;
DWORD i, code;
jsstr_t *ret;
HRESULT hres;
TRACE("\n");
ret = jsstr_alloc_buf(argc);
if(!ret)
ret_str = jsstr_alloc_buf(argc, &ret);
if(!ret_str)
return E_OUTOFMEMORY;
for(i=0; i<argc; i++) {
......@@ -1542,7 +1542,7 @@ static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WOR
return hres;
}
ret->str[i] = code;
ret_str[i] = code;
}
if(r)
......
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