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
c1ab2d06
Commit
c1ab2d06
authored
Feb 27, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag: make tag.num_items unsigned
There's no point in declaring num_items as a uint8_t, it doesn't save any space, due to padding. This allows us to lift the articial "255 items" limitation.
parent
75c2029b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
16 deletions
+6
-16
locate.c
src/locate.c
+1
-2
tag.c
src/tag.c
+4
-13
tag.h
src/tag.h
+1
-1
No files found.
src/locate.c
View file @
c1ab2d06
...
...
@@ -141,7 +141,6 @@ locate_item_free(struct locate_item *item)
static
bool
locate_tag_search
(
const
struct
song
*
song
,
enum
tag_type
type
,
const
char
*
str
)
{
int
i
;
char
*
duplicate
;
bool
ret
=
false
;
bool
visited_types
[
TAG_NUM_OF_ITEM_TYPES
];
...
...
@@ -165,7 +164,7 @@ locate_tag_search(const struct song *song, enum tag_type type, const char *str)
memset
(
visited_types
,
0
,
sizeof
(
visited_types
));
for
(
i
=
0
;
i
<
song
->
tag
->
num_items
&&
!
ret
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
song
->
tag
->
num_items
&&
!
ret
;
i
++
)
{
visited_types
[
song
->
tag
->
items
[
i
]
->
type
]
=
true
;
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
...
...
src/tag.c
View file @
c1ab2d06
...
...
@@ -246,7 +246,7 @@ struct tag *tag_new(void)
return
ret
;
}
static
void
tag_delete_item
(
struct
tag
*
tag
,
int
idx
)
static
void
tag_delete_item
(
struct
tag
*
tag
,
unsigned
idx
)
{
assert
(
idx
<
tag
->
num_items
);
tag
->
num_items
--
;
...
...
@@ -270,9 +270,7 @@ static void tag_delete_item(struct tag *tag, int idx)
void
tag_clear_items_by_type
(
struct
tag
*
tag
,
enum
tag_type
type
)
{
int
i
;
for
(
i
=
0
;
i
<
tag
->
num_items
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
tag
->
num_items
;
i
++
)
{
if
(
tag
->
items
[
i
]
->
type
==
type
)
{
tag_delete_item
(
tag
,
i
);
/* decrement since when just deleted this node */
...
...
@@ -304,7 +302,6 @@ void tag_free(struct tag *tag)
struct
tag
*
tag_dup
(
const
struct
tag
*
tag
)
{
struct
tag
*
ret
;
int
i
;
if
(
!
tag
)
return
NULL
;
...
...
@@ -315,7 +312,7 @@ struct tag *tag_dup(const struct tag *tag)
ret
->
items
=
ret
->
num_items
>
0
?
g_malloc
(
items_size
(
tag
))
:
NULL
;
g_mutex_lock
(
tag_pool_lock
);
for
(
i
=
0
;
i
<
tag
->
num_items
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
tag
->
num_items
;
i
++
)
ret
->
items
[
i
]
=
tag_pool_dup_item
(
tag
->
items
[
i
]);
g_mutex_unlock
(
tag_pool_lock
);
...
...
@@ -388,8 +385,6 @@ bool tag_has_type(const struct tag *tag, enum tag_type type)
bool
tag_equal
(
const
struct
tag
*
tag1
,
const
struct
tag
*
tag2
)
{
int
i
;
if
(
tag1
==
NULL
&&
tag2
==
NULL
)
return
true
;
else
if
(
!
tag1
||
!
tag2
)
...
...
@@ -401,7 +396,7 @@ bool tag_equal(const struct tag *tag1, const struct tag *tag2)
if
(
tag1
->
num_items
!=
tag2
->
num_items
)
return
false
;
for
(
i
=
0
;
i
<
tag1
->
num_items
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
tag1
->
num_items
;
i
++
)
{
if
(
tag1
->
items
[
i
]
->
type
!=
tag2
->
items
[
i
]
->
type
)
return
false
;
if
(
strcmp
(
tag1
->
items
[
i
]
->
value
,
tag2
->
items
[
i
]
->
value
))
{
...
...
@@ -566,9 +561,5 @@ void tag_add_item_n(struct tag *tag, enum tag_type itemType,
if
(
!
value
||
!
len
)
return
;
/* we can't hold more than 255 items */
if
(
tag
->
num_items
==
255
)
return
;
tag_add_item_internal
(
tag
,
itemType
,
value
,
len
);
}
src/tag.h
View file @
c1ab2d06
...
...
@@ -58,7 +58,7 @@ struct tag_item {
struct
tag
{
int
time
;
struct
tag_item
**
items
;
u
int8_t
num_items
;
u
nsigned
num_items
;
};
struct
tag
*
tag_ape_load
(
const
char
*
file
);
...
...
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