[libdmapsharing] Initialize attributes to NULL/0 in add_entry_to_mlcl Signed-off-by: W. Michael Petullo <mike flyn or
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Initialize attributes to NULL/0 in add_entry_to_mlcl Signed-off-by: W. Michael Petullo <mike flyn or
- Date: Sun, 17 Oct 2010 16:26:50 +0000 (UTC)
commit 6a151b4f28cb128f62c58183f716af4fd732e218
Author: W. Michael Petullo <mike flyn org>
Date: Sun Oct 17 11:25:35 2010 -0500
Initialize attributes to NULL/0 in add_entry_to_mlcl
Signed-off-by: W. Michael Petullo <mike flyn org>
README-Memory | 11 +++++++++++
libdmapsharing/daap-share.c | 34 +++++++++++++++++-----------------
libdmapsharing/dpap-share.c | 24 ++++++++++++------------
3 files changed, 40 insertions(+), 29 deletions(-)
---
diff --git a/README-Memory b/README-Memory
index e0d6365..334bbc6 100644
--- a/README-Memory
+++ b/README-Memory
@@ -10,6 +10,17 @@ to increase to over 10 Megabytes. Note that this memory usage might be
smaller on the WRT160NL due to its 32-bit architecture, but it is still
significant in size.
+After attempting to optimize memory use, I measured the following on
+OpenWrt / WRT160NL (*** BUT WITH NO METADATA READ! ***):
+
+Heap, after music is loaded: 0xf5000 (1,003,520)
+Heap, after client received song list: 0x926000 (9,592,832)
+
+SOME METADATA (MP3 ONLY):
+
+Heap, after music is loaded: 0x2d3000 (2,961,408)
+Heap, after client received song list: 0xafa000 (11,509,760)
+
I use the following tools to troubleshoot memory issues:
grep heap /proc/PID/maps (current heap size)
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 7dcd2d5..2120632 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -556,7 +556,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, ITEM_ID))
dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
- gchar *title;
+ gchar *title = NULL;
g_object_get (record, "title", &title, NULL);
if (title) {
dmap_structure_add (mlit, DMAP_CC_MINM, title);
@@ -575,7 +575,7 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_ASUL, "daap://192.168.0.100:%u/databases/1/items/%d.%s?session-id=%s", data->port, *id, daap_record_get_format (DAAP_RECORD (record)), data->session_id);
*/
if (_dmap_share_client_requested (mb->bits, SONG_ALBUM)) {
- gchar *album;
+ gchar *album = NULL;
g_object_get (record, "songalbum", &album, NULL);
if (album) {
dmap_structure_add (mlit, DMAP_CC_ASAL, album);
@@ -586,7 +586,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_GROUPING))
dmap_structure_add (mlit, DMAP_CC_AGRP, "");
if (_dmap_share_client_requested (mb->bits, SONG_ARTIST)) {
- gchar *artist;
+ gchar *artist = NULL;
g_object_get (record, "songartist", &artist, NULL);
if (artist) {
dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
@@ -595,7 +595,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Artist requested but not available");
}
if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) {
- gint32 bitrate;
+ gint32 bitrate = 0;
g_object_get (record, "bitrate", &bitrate, NULL);
if (bitrate != 0)
dmap_structure_add (mlit, DMAP_CC_ASBR, (gint32) bitrate);
@@ -609,19 +609,19 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_COMPOSER))
dmap_structure_add (mlit, DMAP_CC_ASCP, "");
if (_dmap_share_client_requested (mb->bits, SONG_DATE_ADDED)) {
- gint32 firstseen;
+ gint32 firstseen = 0;
g_object_get (record, "firstseen", &firstseen, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDA, firstseen);
}
if (_dmap_share_client_requested (mb->bits, SONG_DATE_MODIFIED)) {
- gint32 mtime;
+ gint32 mtime = 0;
g_object_get (record, "mtime", &mtime, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDM, mtime);
}
if (_dmap_share_client_requested (mb->bits, SONG_DISC_COUNT))
dmap_structure_add (mlit, DMAP_CC_ASDC, (gint32) 0);
if (_dmap_share_client_requested (mb->bits, SONG_DISC_NUMBER)) {
- gint32 disc;
+ gint32 disc = 0;
g_object_get (record, "disc", &disc, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDN, disc);
}
@@ -630,7 +630,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_EQ_PRESET))
dmap_structure_add (mlit, DMAP_CC_ASEQ, "");
if (_dmap_share_client_requested (mb->bits, SONG_FORMAT)) {
- gchar *format;
+ gchar *format = NULL;
if (transcode_format)
format = g_strdup (transcode_format);
else
@@ -642,7 +642,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Format requested but not available");
}
if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) {
- gchar *genre;
+ gchar *genre = NULL;
g_object_get (record, "songgenre", &genre, NULL);
if (genre) {
dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
@@ -657,7 +657,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_SAMPLE_RATE))
dmap_structure_add (mlit, DMAP_CC_ASSR, 0);
if (_dmap_share_client_requested (mb->bits, SONG_SIZE)) {
- guint64 filesize;
+ guint64 filesize = 0;
g_object_get (record, "filesize", &filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_ASSZ, (gint32) filesize);
}
@@ -673,27 +673,27 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_TRACK_COUNT))
dmap_structure_add (mlit, DMAP_CC_ASTC, 0);
if (_dmap_share_client_requested (mb->bits, SONG_TRACK_NUMBER)) {
- gint32 track;
+ gint32 track = 0;
g_object_get (record, "track", &track, NULL);
dmap_structure_add (mlit, DMAP_CC_ASTN, track);
}
if (_dmap_share_client_requested (mb->bits, SONG_USER_RATING)) {
- gint32 rating;
+ gint32 rating = 0;
g_object_get (record, "rating", &rating, NULL);
dmap_structure_add (mlit, DMAP_CC_ASUR, rating);
}
if (_dmap_share_client_requested (mb->bits, SONG_YEAR)) {
- gint32 year;
+ gint32 year = 0;
g_object_get (record, "year", &year, NULL);
dmap_structure_add (mlit, DMAP_CC_ASYR, year);
}
if (_dmap_share_client_requested (mb->bits, SONG_HAS_VIDEO)) {
- gboolean has_video;
+ gboolean has_video = 0;
g_object_get (record, "has-video", &has_video, NULL);
dmap_structure_add (mlit, DMAP_CC_AEHV, has_video);
}
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ARTIST)) {
- gchar *sort_artist;
+ gchar *sort_artist = NULL;
g_object_get (record, "sort-artist", &sort_artist, NULL);
if (sort_artist)
dmap_structure_add (mlit, DMAP_CC_ASSA, sort_artist);
@@ -701,7 +701,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Sort artist requested but not available");
}
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ALBUM)) {
- gchar *sort_album;
+ gchar *sort_album = NULL;
g_object_get (record, "sort-album", &sort_album, NULL);
if (sort_album)
dmap_structure_add (mlit, DMAP_CC_ASSU, sort_album);
@@ -709,7 +709,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Sort album requested but not available");
}
if (_dmap_share_client_requested (mb->bits, SONG_MEDIAKIND)) {
- gint mediakind;
+ gint mediakind = 0;
g_object_get (record, "mediakind", &mediakind, NULL);
dmap_structure_add (mlit, DMAP_CC_AEMK, mediakind);
}
diff --git a/libdmapsharing/dpap-share.c b/libdmapsharing/dpap-share.c
index dfe53ad..1ae4b6d 100644
--- a/libdmapsharing/dpap-share.c
+++ b/libdmapsharing/dpap-share.c
@@ -361,7 +361,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, ITEM_ID))
dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
- gchar *filename;
+ gchar *filename = NULL;
g_object_get (record, "filename", &filename, NULL);
if (filename) {
dmap_structure_add (mlit, DMAP_CC_MINM, filename);
@@ -374,7 +374,7 @@ add_entry_to_mlcl (gpointer id,
if (TRUE) {
/* dpap-sharp claims iPhoto '08 will not show thumbnails without PASP
* and this does seem to be the case when testing. */
- gchar *aspect_ratio;
+ gchar *aspect_ratio = NULL;
g_object_get (record, "aspect-ratio", &aspect_ratio, NULL);
if (aspect_ratio) {
dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio);
@@ -383,12 +383,12 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Aspect ratio requested but not available");
}
if (_dmap_share_client_requested (mb->bits, PHOTO_CREATIONDATE)) {
- gint creation_date;
+ gint creation_date = 0;
g_object_get (record, "creation-date", &creation_date, NULL);
dmap_structure_add (mlit, DMAP_CC_PICD, creation_date);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILENAME)) {
- gchar *filename;
+ gchar *filename = NULL;
g_object_get (record, "filename", &filename, NULL);
if (filename) {
dmap_structure_add (mlit, DMAP_CC_PIMF, filename);
@@ -397,7 +397,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Filename requested but not available");
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFORMAT)) {
- gchar *format;
+ gchar *format = NULL;
g_object_get (record, "format", &format, NULL);
if (format) {
dmap_structure_add (mlit, DMAP_CC_PFMT, format);
@@ -406,32 +406,32 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Format requested but not available");
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILESIZE)) {
- gint filesize;
+ gint filesize = 0;
g_object_get (record, "filesize", &filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_PIFS, filesize);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGELARGEFILESIZE)) {
- gint large_filesize;
+ gint large_filesize = 0;
g_object_get (record, "large-filesize", &large_filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_PLSZ, large_filesize);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEPIXELHEIGHT)) {
- gint pixel_height;
+ gint pixel_height = 0;
g_object_get (record, "pixel-height", &pixel_height, NULL);
dmap_structure_add (mlit, DMAP_CC_PHGT, pixel_height);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEPIXELWIDTH)) {
- gint pixel_width;
+ gint pixel_width = 0;
g_object_get (record, "pixel-width", &pixel_width, NULL);
dmap_structure_add (mlit, DMAP_CC_PWTH, pixel_width);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGERATING)) {
- gint rating;
+ gint rating = 0;
g_object_get (record, "rating", &rating, NULL);
dmap_structure_add (mlit, DMAP_CC_PRAT, rating);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGECOMMENTS)) {
- gchar *comments;
+ gchar *comments = NULL;
g_object_get (record, "comments", &comments, NULL);
if (comments) {
dmap_structure_add (mlit, DMAP_CC_PCMT, comments);
@@ -447,7 +447,7 @@ add_entry_to_mlcl (gpointer id,
g_object_get (record, "filesize", &size, NULL);
} else {
/* Should be PHOTO_HIRES */
- char *location;
+ char *location = NULL;
g_object_get (record, "location", &location, NULL);
if (mapped_file) {
/* Free any previously mapped image */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]