aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:39:12 +0200
committerMax Kellermann <max@duempel.org>2008-08-29 09:39:12 +0200
commit5bd5551630c55344a11f99565d3c53acb32c0e44 (patch)
tree8d6c23d6ffc4381b6738b64678c3abdf9fefe446 /src
parent1aa3457346b6c88d4d43e6faf5cde2ae95f36275 (diff)
downloadmpd-5bd5551630c55344a11f99565d3c53acb32c0e44.tar.gz
mpd-5bd5551630c55344a11f99565d3c53acb32c0e44.tar.xz
mpd-5bd5551630c55344a11f99565d3c53acb32c0e44.zip
tag: static directory name
While parsing the tag cache, don't allocate the directory name from the heap, but copy it into a buffer on the stack. This reduces heap fragmentation by 1%.
Diffstat (limited to 'src')
-rw-r--r--src/directory.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/directory.c b/src/directory.c
index 46d309c76..5375d8dd1 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -901,7 +901,7 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
{
char buffer[MPD_PATH_MAX * 2];
int bufferSize = MPD_PATH_MAX * 2;
- char *key;
+ char key[MPD_PATH_MAX * 2];
Directory *subDirectory;
int strcmpRet;
char *name;
@@ -911,7 +911,7 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
while (myFgets(buffer, bufferSize, fp)
&& 0 != strncmp(DIRECTORY_END, buffer, strlen(DIRECTORY_END))) {
if (0 == strncmp(DIRECTORY_DIR, buffer, strlen(DIRECTORY_DIR))) {
- key = xstrdup(&(buffer[strlen(DIRECTORY_DIR)]));
+ strcpy(key, &(buffer[strlen(DIRECTORY_DIR)]));
if (!myFgets(buffer, bufferSize, fp))
FATAL("Error reading db, fgets\n");
/* for compatibility with db's prior to 0.11 */
@@ -925,7 +925,7 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
strlen(DIRECTORY_BEGIN))) {
FATAL("Error reading db at line: %s\n", buffer);
}
- name = xstrdup(&(buffer[strlen(DIRECTORY_BEGIN)]));
+ name = &(buffer[strlen(DIRECTORY_BEGIN)]);
while (nextDirNode && (strcmpRet =
strcmp(key,
@@ -951,8 +951,6 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
(void *)subDirectory);
}
- free(name);
- free(key);
readDirectoryInfo(fp, subDirectory);
} else if (0 == strncmp(SONG_BEGIN, buffer, strlen(SONG_BEGIN))) {
readSongInfoIntoList(fp, directory->songs, directory);