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
f1285a6d
Commit
f1285a6d
authored
Mar 14, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/TagPool: add constexpr MAX_REF
parent
cf7c1afb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
TagPool.cxx
src/tag/TagPool.cxx
+7
-3
No files found.
src/tag/TagPool.cxx
View file @
f1285a6d
...
...
@@ -23,6 +23,8 @@
#include "util/Cast.hxx"
#include "util/VarSize.hxx"
#include <limits>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
...
...
@@ -36,6 +38,8 @@ struct TagPoolSlot {
unsigned
char
ref
;
TagItem
item
;
static
constexpr
unsigned
MAX_REF
=
std
::
numeric_limits
<
decltype
(
ref
)
>::
max
();
TagPoolSlot
(
TagPoolSlot
*
_next
,
TagType
type
,
const
char
*
value
,
size_t
length
)
:
next
(
_next
),
ref
(
1
)
{
...
...
@@ -116,7 +120,7 @@ tag_pool_get_item(TagType type, const char *value, size_t length)
if
(
slot
->
item
.
type
==
type
&&
length
==
strlen
(
slot
->
item
.
value
)
&&
memcmp
(
value
,
slot
->
item
.
value
,
length
)
==
0
&&
slot
->
ref
<
0xff
)
{
slot
->
ref
<
TagPoolSlot
::
MAX_REF
)
{
assert
(
slot
->
ref
>
0
);
++
slot
->
ref
;
return
&
slot
->
item
;
...
...
@@ -135,11 +139,11 @@ tag_pool_dup_item(TagItem *item)
assert
(
slot
->
ref
>
0
);
if
(
slot
->
ref
<
0xff
)
{
if
(
slot
->
ref
<
TagPoolSlot
::
MAX_REF
)
{
++
slot
->
ref
;
return
item
;
}
else
{
/* the reference counter overflows above
0xff
;
/* the reference counter overflows above
MAX_REF
;
duplicate the item, and start with 1 */
size_t
length
=
strlen
(
item
->
value
);
auto
slot_p
=
tag_value_slot_p
(
item
->
type
,
...
...
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