Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
c180a902
Commit
c180a902
authored
Nov 17, 2023
by
Piotr Caban
Committed by
Alexandre Julliard
Nov 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Avoid temporary buffer allocation in _mbsrev_l.
parent
71b3d10f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
35 deletions
+15
-35
mbcs.c
dlls/msvcrt/mbcs.c
+15
-35
No files found.
dlls/msvcrt/mbcs.c
View file @
c180a902
...
...
@@ -2889,9 +2889,8 @@ size_t CDECL _mbscspn(const unsigned char* str, const unsigned char* cmp)
*/
unsigned
char
*
CDECL
_mbsrev_l
(
unsigned
char
*
str
,
_locale_t
locale
)
{
int
i
,
len
;
unsigned
char
*
p
,
*
temp
;
pthreadmbcinfo
mbcinfo
;
unsigned
char
*
p
,
tmp
;
if
(
!
MSVCRT_CHECK_PMT
(
str
))
return
NULL
;
...
...
@@ -2904,44 +2903,25 @@ unsigned char* CDECL _mbsrev_l(unsigned char* str, _locale_t locale)
if
(
!
mbcinfo
->
ismbcodepage
)
return
u__strrev
(
str
);
len
=
_mbslen_l
(
str
,
locale
);
temp
=
malloc
(
len
*
2
);
if
(
!
temp
)
return
str
;
/* unpack multibyte string to temp buffer */
p
=
str
;
for
(
i
=
0
;
i
<
len
;
i
++
)
for
(
p
=
str
;
*
p
;
p
++
)
{
if
(
_ismbblead_l
(
*
p
,
locale
))
{
temp
[
i
*
2
]
=
*
p
++
;
temp
[
i
*
2
+
1
]
=
*
p
++
;
}
else
{
temp
[
i
*
2
]
=
*
p
++
;
temp
[
i
*
2
+
1
]
=
0
;
}
}
/* repack it in the reverse order */
p
=
str
;
for
(
i
=
len
-
1
;
i
>=
0
;
i
--
)
{
if
(
_ismbblead_l
(
temp
[
i
*
2
],
locale
))
{
*
p
++
=
temp
[
i
*
2
];
*
p
++
=
temp
[
i
*
2
+
1
];
}
else
{
*
p
++
=
temp
[
i
*
2
];
if
(
p
[
1
])
{
tmp
=
p
[
0
];
p
[
0
]
=
p
[
1
];
p
[
1
]
=
tmp
;
p
++
;
}
else
{
/* drop trailing lead char */
p
[
0
]
=
0
;
}
}
}
free
(
temp
);
return
str
;
return
u__strrev
(
str
);
}
/*********************************************************************
...
...
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