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
d6472906
Commit
d6472906
authored
Oct 08, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Parser: use std::size_t
parent
ab318200
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
Parser.cxx
src/config/Parser.cxx
+10
-10
Parser.hxx
src/config/Parser.hxx
+2
-2
No files found.
src/config/Parser.cxx
View file @
d6472906
...
...
@@ -70,28 +70,28 @@ ParsePositive(const char *s)
return
(
unsigned
)
value
;
}
template
<
size_t
OPERAND
>
static
size_t
Multiply
(
size_t
value
)
template
<
s
td
::
s
ize_t
OPERAND
>
static
s
td
::
s
ize_t
Multiply
(
s
td
::
s
ize_t
value
)
{
static
constexpr
size_t
MAX_VALUE
=
SIZE_MAX
/
OPERAND
;
static
constexpr
s
td
::
s
ize_t
MAX_VALUE
=
SIZE_MAX
/
OPERAND
;
if
(
value
>
MAX_VALUE
)
throw
std
::
runtime_error
(
"Value too large"
);
return
value
*
OPERAND
;
}
size_t
ParseSize
(
const
char
*
s
,
size_t
default_factor
)
s
td
::
s
ize_t
ParseSize
(
const
char
*
s
,
s
td
::
s
ize_t
default_factor
)
{
char
*
endptr
;
size_t
value
=
strtoul
(
s
,
&
endptr
,
10
);
s
td
::
s
ize_t
value
=
strtoul
(
s
,
&
endptr
,
10
);
if
(
endptr
==
s
)
throw
std
::
runtime_error
(
"Failed to parse integer"
);
static
constexpr
size_t
KILO
=
1024
;
static
constexpr
size_t
MEGA
=
1024
*
KILO
;
static
constexpr
size_t
GIGA
=
1024
*
MEGA
;
static
constexpr
s
td
::
s
ize_t
KILO
=
1024
;
static
constexpr
s
td
::
s
ize_t
MEGA
=
1024
*
KILO
;
static
constexpr
s
td
::
s
ize_t
GIGA
=
1024
*
MEGA
;
s
=
StripLeft
(
endptr
);
...
...
src/config/Parser.hxx
View file @
d6472906
...
...
@@ -51,7 +51,7 @@ ParsePositive(const char *s);
*
* Throws on error.
*/
size_t
ParseSize
(
const
char
*
s
,
size_t
default_factor
=
1
);
s
td
::
s
ize_t
ParseSize
(
const
char
*
s
,
s
td
::
s
ize_t
default_factor
=
1
);
#endif
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