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
ffe68936
Commit
ffe68936
authored
Sep 01, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/AllocatedString: add constant "SENTINEL"
parent
48d7fedb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
AllocatedString.hxx
src/util/AllocatedString.hxx
+6
-4
No files found.
src/util/AllocatedString.hxx
View file @
ffe68936
...
...
@@ -47,6 +47,8 @@ public:
typedef
typename
StringPointer
<
T
>::
pointer
pointer
;
typedef
typename
StringPointer
<
T
>::
const_pointer
const_pointer
;
static
constexpr
value_type
SENTINEL
=
'\0'
;
private
:
pointer
value
;
...
...
@@ -73,7 +75,7 @@ public:
static
AllocatedString
Empty
()
{
auto
p
=
new
value_type
[
1
];
p
[
0
]
=
value_type
(
0
)
;
p
[
0
]
=
SENTINEL
;
return
Donate
(
p
);
}
...
...
@@ -82,14 +84,14 @@ public:
static
AllocatedString
Duplicate
(
const_pointer
begin
,
const_pointer
end
)
{
auto
p
=
new
value_type
[
end
-
begin
+
1
];
*
std
::
copy
(
begin
,
end
,
p
)
=
0
;
*
std
::
copy
(
begin
,
end
,
p
)
=
SENTINEL
;
return
Donate
(
p
);
}
static
AllocatedString
Duplicate
(
const_pointer
begin
,
size_t
length
)
{
auto
p
=
new
value_type
[
length
];
*
std
::
copy_n
(
begin
,
length
,
p
)
=
0
;
*
std
::
copy_n
(
begin
,
length
,
p
)
=
SENTINEL
;
return
Donate
(
p
);
}
...
...
@@ -107,7 +109,7 @@ public:
}
bool
empty
()
const
{
return
*
value
==
0
;
return
*
value
==
SENTINEL
;
}
pointer
Steal
()
{
...
...
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