Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
29d9d668
Commit
29d9d668
authored
Mar 30, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Apr 01, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Moved string buffer to separated struct from jsstr_t.
parent
c79180a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
jsstr.c
dlls/jscript/jsstr.c
+9
-9
jsstr.h
dlls/jscript/jsstr.h
+14
-5
No files found.
dlls/jscript/jsstr.c
View file @
29d9d668
...
...
@@ -22,25 +22,25 @@
const
char
*
debugstr_jsstr
(
jsstr_t
*
str
)
{
return
debugstr_wn
(
str
->
str
,
jsstr_length
(
str
));
return
debugstr_wn
(
jsstr_as_inline
(
str
)
->
buf
,
jsstr_length
(
str
));
}
WCHAR
*
jsstr_alloc_buf
(
unsigned
len
,
jsstr_t
**
r
)
{
jsstr_t
*
ret
;
jsstr_
inline_
t
*
ret
;
if
(
len
>
JSSTR_MAX_LENGTH
)
return
NULL
;
ret
=
heap_alloc
(
FIELD_OFFSET
(
jsstr_
t
,
str
[
len
+
1
]));
ret
=
heap_alloc
(
FIELD_OFFSET
(
jsstr_
inline_t
,
buf
[
len
+
1
]));
if
(
!
ret
)
return
NULL
;
ret
->
length_flags
=
len
<<
JSSTR_LENGTH_SHIFT
;
ret
->
ref
=
1
;
ret
->
str
[
len
]
=
0
;
*
r
=
ret
;
return
ret
->
str
;
ret
->
str
.
length_flags
=
len
<<
JSSTR_LENGTH_SHIFT
;
ret
->
str
.
ref
=
1
;
ret
->
buf
[
len
]
=
0
;
*
r
=
&
ret
->
str
;
return
ret
->
buf
;
}
jsstr_t
*
jsstr_alloc_len
(
const
WCHAR
*
buf
,
unsigned
len
)
...
...
@@ -61,7 +61,7 @@ int jsstr_cmp(jsstr_t *str1, jsstr_t *str2)
int
len2
=
jsstr_length
(
str2
);
int
ret
;
ret
=
memcmp
(
str1
->
str
,
str2
->
str
,
min
(
len1
,
len2
)
*
sizeof
(
WCHAR
));
ret
=
memcmp
(
jsstr_as_inline
(
str1
)
->
buf
,
jsstr_as_inline
(
str2
)
->
buf
,
min
(
len1
,
len2
)
*
sizeof
(
WCHAR
));
if
(
!
ret
)
ret
=
len1
-
len2
;
...
...
dlls/jscript/jsstr.h
View file @
29d9d668
...
...
@@ -19,7 +19,6 @@
struct
_jsstr_t
{
unsigned
length_flags
;
unsigned
ref
;
WCHAR
str
[
1
];
};
#define JSSTR_LENGTH_SHIFT 4
...
...
@@ -33,6 +32,11 @@ static inline unsigned jsstr_length(jsstr_t *str)
return
str
->
length_flags
>>
JSSTR_LENGTH_SHIFT
;
}
typedef
struct
{
jsstr_t
str
;
WCHAR
buf
[
1
];
}
jsstr_inline_t
;
jsstr_t
*
jsstr_alloc_len
(
const
WCHAR
*
,
unsigned
)
DECLSPEC_HIDDEN
;
WCHAR
*
jsstr_alloc_buf
(
unsigned
,
jsstr_t
**
)
DECLSPEC_HIDDEN
;
...
...
@@ -53,27 +57,32 @@ static inline jsstr_t *jsstr_addref(jsstr_t *str)
return
str
;
}
static
inline
jsstr_inline_t
*
jsstr_as_inline
(
jsstr_t
*
str
)
{
return
CONTAINING_RECORD
(
str
,
jsstr_inline_t
,
str
);
}
/* This will be failable in the future. */
static
inline
const
WCHAR
*
jsstr_flatten
(
jsstr_t
*
str
)
{
return
str
->
str
;
return
jsstr_as_inline
(
str
)
->
buf
;
}
static
inline
BOOL
jsstr_eq
(
jsstr_t
*
str1
,
jsstr_t
*
str2
)
{
unsigned
len
=
jsstr_length
(
str1
);
return
len
==
jsstr_length
(
str2
)
&&
!
memcmp
(
str1
->
str
,
str2
->
str
,
len
*
sizeof
(
WCHAR
));
return
len
==
jsstr_length
(
str2
)
&&
!
memcmp
(
jsstr_as_inline
(
str1
)
->
buf
,
jsstr_as_inline
(
str2
)
->
buf
,
len
*
sizeof
(
WCHAR
));
}
static
inline
void
jsstr_extract
(
jsstr_t
*
str
,
unsigned
off
,
unsigned
len
,
WCHAR
*
buf
)
{
memcpy
(
buf
,
str
->
str
+
off
,
len
*
sizeof
(
WCHAR
));
memcpy
(
buf
,
jsstr_as_inline
(
str
)
->
buf
+
off
,
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
));
memcpy
(
buf
,
jsstr_as_inline
(
str
)
->
buf
,
len
*
sizeof
(
WCHAR
));
return
len
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment