Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
6b83fc6b
Commit
6b83fc6b
authored
Mar 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32/HResult: un-inline FormatHResultError()
Reduce header dependencies.
parent
74f9e071
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
18 deletions
+45
-18
HResult.cxx
src/win32/HResult.cxx
+42
-0
HResult.hxx
src/win32/HResult.hxx
+2
-18
meson.build
src/win32/meson.build
+1
-0
No files found.
src/win32/HResult.cxx
0 → 100644
View file @
6b83fc6b
/*
* Copyright 2020-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "HResult.hxx"
#include <cstdarg>
#include <memory>
std
::
system_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
{
std
::
va_list
args1
,
args2
;
va_start
(
args1
,
fmt
);
va_copy
(
args2
,
args1
);
const
int
size
=
vsnprintf
(
nullptr
,
0
,
fmt
,
args1
);
va_end
(
args1
);
assert
(
size
>=
0
);
auto
buffer
=
std
::
make_unique
<
char
[]
>
(
size
+
1
);
vsprintf
(
buffer
.
get
(),
fmt
,
args2
);
va_end
(
args2
);
return
std
::
system_error
(
std
::
error_code
(
result
,
hresult_category
()),
std
::
string
(
buffer
.
get
(),
size
));
}
src/win32/HResult.hxx
View file @
6b83fc6b
...
...
@@ -23,7 +23,6 @@
#include "util/Compiler.h"
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <string_view>
#include <system_error>
...
...
@@ -86,22 +85,7 @@ static inline const std::error_category &hresult_category() noexcept {
return
hresult_category_instance
;
}
gcc_printf
(
2
,
3
)
static
inline
std
::
system_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
{
std
::
va_list
args1
,
args2
;
va_start
(
args1
,
fmt
);
va_copy
(
args2
,
args1
);
const
int
size
=
vsnprintf
(
nullptr
,
0
,
fmt
,
args1
);
va_end
(
args1
);
assert
(
size
>=
0
);
auto
buffer
=
std
::
make_unique
<
char
[]
>
(
size
+
1
);
vsprintf
(
buffer
.
get
(),
fmt
,
args2
);
va_end
(
args2
);
return
std
::
system_error
(
std
::
error_code
(
result
,
hresult_category
()),
std
::
string
(
buffer
.
get
(),
size
));
}
gcc_printf
(
2
,
3
)
std
::
system_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
;
#endif
src/win32/meson.build
View file @
6b83fc6b
...
...
@@ -6,6 +6,7 @@ endif
win32 = static_library(
'win32',
'ComWorker.cxx',
'HResult.cxx',
include_directories: inc,
)
...
...
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