aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:39:12 +0200
committerEric Wong <normalperson@yhbt.net>2008-09-02 00:20:21 -0700
commit7f04d26b6fcfe8c7fcc23c5accddda02ea36c507 (patch)
tree26423bde6d7ece186bd3397f8cc55e9b7fab4a42 /src
parentc82544458231694c197b0c967f6e2844e8612bc6 (diff)
downloadmpd-7f04d26b6fcfe8c7fcc23c5accddda02ea36c507.tar.gz
mpd-7f04d26b6fcfe8c7fcc23c5accddda02ea36c507.tar.xz
mpd-7f04d26b6fcfe8c7fcc23c5accddda02ea36c507.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 94a55d664..33a862ddd 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);