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
ad0e09b2
Commit
ad0e09b2
authored
Aug 29, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag: converted MpdTag.items to a pointer list
This prepares the following patches, which aim to reduce MPD's memory usage: we plan to share tag_item instances, instead of just their values.
parent
6f72fe3e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
17 deletions
+20
-17
dbUtils.c
src/dbUtils.c
+2
-2
locate.c
src/locate.c
+4
-4
tag.c
src/tag.c
+13
-10
tag.h
src/tag.h
+1
-1
No files found.
src/dbUtils.c
View file @
ad0e09b2
...
@@ -268,8 +268,8 @@ static void visitTag(int fd, Song * song, enum tag_type tagType)
...
@@ -268,8 +268,8 @@ static void visitTag(int fd, Song * song, enum tag_type tagType)
return
;
return
;
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
if
(
tag
->
items
[
i
]
.
type
==
tagType
)
{
if
(
tag
->
items
[
i
]
->
type
==
tagType
)
{
visitInTagTracker
(
tagType
,
tag
->
items
[
i
]
.
value
);
visitInTagTracker
(
tagType
,
tag
->
items
[
i
]
->
value
);
}
}
}
}
}
}
...
...
src/locate.c
View file @
ad0e09b2
...
@@ -142,11 +142,11 @@ static int strstrSearchTag(Song * song, enum tag_type type, char *str)
...
@@ -142,11 +142,11 @@ static int strstrSearchTag(Song * song, enum tag_type type, char *str)
for
(
i
=
0
;
i
<
song
->
tag
->
numOfItems
&&
!
ret
;
i
++
)
{
for
(
i
=
0
;
i
<
song
->
tag
->
numOfItems
&&
!
ret
;
i
++
)
{
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
.
type
!=
type
)
{
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
continue
;
continue
;
}
}
duplicate
=
strDupToUpper
(
song
->
tag
->
items
[
i
]
.
value
);
duplicate
=
strDupToUpper
(
song
->
tag
->
items
[
i
]
->
value
);
if
(
strstr
(
duplicate
,
str
))
if
(
strstr
(
duplicate
,
str
))
ret
=
1
;
ret
=
1
;
free
(
duplicate
);
free
(
duplicate
);
...
@@ -186,11 +186,11 @@ static int tagItemFoundAndMatches(Song * song, enum tag_type type, char *str)
...
@@ -186,11 +186,11 @@ static int tagItemFoundAndMatches(Song * song, enum tag_type type, char *str)
for
(
i
=
0
;
i
<
song
->
tag
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
song
->
tag
->
numOfItems
;
i
++
)
{
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
if
(
type
!=
LOCATE_TAG_ANY_TYPE
&&
song
->
tag
->
items
[
i
]
.
type
!=
type
)
{
song
->
tag
->
items
[
i
]
->
type
!=
type
)
{
continue
;
continue
;
}
}
if
(
0
==
strcmp
(
str
,
song
->
tag
->
items
[
i
]
.
value
))
if
(
0
==
strcmp
(
str
,
song
->
tag
->
items
[
i
]
->
value
))
return
1
;
return
1
;
}
}
...
...
src/tag.c
View file @
ad0e09b2
...
@@ -108,8 +108,8 @@ void tag_print(int fd, struct tag *tag)
...
@@ -108,8 +108,8 @@ void tag_print(int fd, struct tag *tag)
fdprintf
(
fd
,
SONG_TIME
"%i
\n
"
,
tag
->
time
);
fdprintf
(
fd
,
SONG_TIME
"%i
\n
"
,
tag
->
time
);
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
fdprintf
(
fd
,
"%s: %s
\n
"
,
mpdTagItemKeys
[
tag
->
items
[
i
]
.
type
],
fdprintf
(
fd
,
"%s: %s
\n
"
,
mpdTagItemKeys
[
tag
->
items
[
i
]
->
type
],
tag
->
items
[
i
]
.
value
);
tag
->
items
[
i
]
->
value
);
}
}
}
}
...
@@ -248,7 +248,8 @@ static void deleteItem(struct tag *tag, int idx)
...
@@ -248,7 +248,8 @@ static void deleteItem(struct tag *tag, int idx)
assert
(
idx
<
tag
->
numOfItems
);
assert
(
idx
<
tag
->
numOfItems
);
tag
->
numOfItems
--
;
tag
->
numOfItems
--
;
removeTagItemString
(
tag
->
items
[
idx
].
type
,
tag
->
items
[
idx
].
value
);
removeTagItemString
(
tag
->
items
[
idx
]
->
type
,
tag
->
items
[
idx
]
->
value
);
free
(
tag
->
items
[
idx
]);
/* free(tag->items[idx].value); */
/* free(tag->items[idx].value); */
if
(
tag
->
numOfItems
-
idx
>
0
)
{
if
(
tag
->
numOfItems
-
idx
>
0
)
{
...
@@ -270,7 +271,7 @@ void tag_clear_items_by_type(struct tag *tag, enum tag_type type)
...
@@ -270,7 +271,7 @@ void tag_clear_items_by_type(struct tag *tag, enum tag_type type)
int
i
;
int
i
;
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
if
(
tag
->
items
[
i
]
.
type
==
type
)
{
if
(
tag
->
items
[
i
]
->
type
==
type
)
{
deleteItem
(
tag
,
i
);
deleteItem
(
tag
,
i
);
/* decrement since when just deleted this node */
/* decrement since when just deleted this node */
i
--
;
i
--
;
...
@@ -283,8 +284,9 @@ static void clearMpdTag(struct tag *tag)
...
@@ -283,8 +284,9 @@ static void clearMpdTag(struct tag *tag)
int
i
;
int
i
;
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
removeTagItemString
(
tag
->
items
[
i
]
.
type
,
tag
->
items
[
i
].
value
);
removeTagItemString
(
tag
->
items
[
i
]
->
type
,
tag
->
items
[
i
]
->
value
);
/* free(tag->items[i].value); */
/* free(tag->items[i].value); */
free
(
tag
->
items
[
i
]);
}
}
if
(
tag
->
items
)
if
(
tag
->
items
)
...
@@ -314,7 +316,7 @@ struct tag *tag_dup(struct tag *tag)
...
@@ -314,7 +316,7 @@ struct tag *tag_dup(struct tag *tag)
ret
->
time
=
tag
->
time
;
ret
->
time
=
tag
->
time
;
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
{
tag_add_item
(
ret
,
tag
->
items
[
i
]
.
type
,
tag
->
items
[
i
].
value
);
tag_add_item
(
ret
,
tag
->
items
[
i
]
->
type
,
tag
->
items
[
i
]
->
value
);
}
}
return
ret
;
return
ret
;
...
@@ -336,9 +338,9 @@ int tag_equal(struct tag *tag1, struct tag *tag2)
...
@@ -336,9 +338,9 @@ int tag_equal(struct tag *tag1, struct tag *tag2)
return
0
;
return
0
;
for
(
i
=
0
;
i
<
tag1
->
numOfItems
;
i
++
)
{
for
(
i
=
0
;
i
<
tag1
->
numOfItems
;
i
++
)
{
if
(
tag1
->
items
[
i
]
.
type
!=
tag2
->
items
[
i
].
type
)
if
(
tag1
->
items
[
i
]
->
type
!=
tag2
->
items
[
i
]
->
type
)
return
0
;
return
0
;
if
(
strcmp
(
tag1
->
items
[
i
]
.
value
,
tag2
->
items
[
i
].
value
))
{
if
(
strcmp
(
tag1
->
items
[
i
]
->
value
,
tag2
->
items
[
i
]
->
value
))
{
return
0
;
return
0
;
}
}
}
}
...
@@ -372,8 +374,9 @@ static void appendToTagItems(struct tag *tag, enum tag_type type,
...
@@ -372,8 +374,9 @@ static void appendToTagItems(struct tag *tag, enum tag_type type,
tag
->
items
=
xrealloc
(
tag
->
items
,
tag
->
items
=
xrealloc
(
tag
->
items
,
tag
->
numOfItems
*
sizeof
(
*
tag
->
items
));
tag
->
numOfItems
*
sizeof
(
*
tag
->
items
));
tag
->
items
[
i
].
type
=
type
;
tag
->
items
[
i
]
=
xmalloc
(
sizeof
(
*
tag
->
items
[
i
]));
tag
->
items
[
i
].
value
=
getTagItemString
(
type
,
duplicated
);
tag
->
items
[
i
]
->
type
=
type
;
tag
->
items
[
i
]
->
value
=
getTagItemString
(
type
,
duplicated
);
free
(
duplicated
);
free
(
duplicated
);
}
}
...
...
src/tag.h
View file @
ad0e09b2
...
@@ -46,7 +46,7 @@ struct tag_item {
...
@@ -46,7 +46,7 @@ struct tag_item {
struct
tag
{
struct
tag
{
int
time
;
int
time
;
struct
tag_item
*
items
;
struct
tag_item
*
*
items
;
mpd_uint8
numOfItems
;
mpd_uint8
numOfItems
;
};
};
...
...
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