Commit 6a151b4f authored by W. Michael Petullo's avatar W. Michael Petullo
Browse files

Initialize attributes to NULL/0 in add_entry_to_mlcl


Signed-off-by: W. Michael Petullo's avatarW. Michael Petullo <mike@flyn.org>
parent 6835bd86
...@@ -10,6 +10,17 @@ to increase to over 10 Megabytes. Note that this memory usage might be ...@@ -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 smaller on the WRT160NL due to its 32-bit architecture, but it is still
significant in size. 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: I use the following tools to troubleshoot memory issues:
grep heap /proc/PID/maps (current heap size) grep heap /proc/PID/maps (current heap size)
......
...@@ -556,7 +556,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -556,7 +556,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, ITEM_ID)) if (_dmap_share_client_requested (mb->bits, ITEM_ID))
dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id)); dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) { if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
gchar *title; gchar *title = NULL;
g_object_get (record, "title", &title, NULL); g_object_get (record, "title", &title, NULL);
if (title) { if (title) {
dmap_structure_add (mlit, DMAP_CC_MINM, title); dmap_structure_add (mlit, DMAP_CC_MINM, title);
...@@ -575,7 +575,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -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); 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)) { if (_dmap_share_client_requested (mb->bits, SONG_ALBUM)) {
gchar *album; gchar *album = NULL;
g_object_get (record, "songalbum", &album, NULL); g_object_get (record, "songalbum", &album, NULL);
if (album) { if (album) {
dmap_structure_add (mlit, DMAP_CC_ASAL, album); dmap_structure_add (mlit, DMAP_CC_ASAL, album);
...@@ -586,7 +586,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -586,7 +586,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_GROUPING)) if (_dmap_share_client_requested (mb->bits, SONG_GROUPING))
dmap_structure_add (mlit, DMAP_CC_AGRP, ""); dmap_structure_add (mlit, DMAP_CC_AGRP, "");
if (_dmap_share_client_requested (mb->bits, SONG_ARTIST)) { if (_dmap_share_client_requested (mb->bits, SONG_ARTIST)) {
gchar *artist; gchar *artist = NULL;
g_object_get (record, "songartist", &artist, NULL); g_object_get (record, "songartist", &artist, NULL);
if (artist) { if (artist) {
dmap_structure_add (mlit, DMAP_CC_ASAR, artist); dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
...@@ -595,7 +595,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -595,7 +595,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Artist requested but not available"); g_warning ("Artist requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) { if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) {
gint32 bitrate; gint32 bitrate = 0;
g_object_get (record, "bitrate", &bitrate, NULL); g_object_get (record, "bitrate", &bitrate, NULL);
if (bitrate != 0) if (bitrate != 0)
dmap_structure_add (mlit, DMAP_CC_ASBR, (gint32) bitrate); dmap_structure_add (mlit, DMAP_CC_ASBR, (gint32) bitrate);
...@@ -609,19 +609,19 @@ add_entry_to_mlcl (gpointer id, ...@@ -609,19 +609,19 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_COMPOSER)) if (_dmap_share_client_requested (mb->bits, SONG_COMPOSER))
dmap_structure_add (mlit, DMAP_CC_ASCP, ""); dmap_structure_add (mlit, DMAP_CC_ASCP, "");
if (_dmap_share_client_requested (mb->bits, SONG_DATE_ADDED)) { if (_dmap_share_client_requested (mb->bits, SONG_DATE_ADDED)) {
gint32 firstseen; gint32 firstseen = 0;
g_object_get (record, "firstseen", &firstseen, NULL); g_object_get (record, "firstseen", &firstseen, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDA, firstseen); dmap_structure_add (mlit, DMAP_CC_ASDA, firstseen);
} }
if (_dmap_share_client_requested (mb->bits, SONG_DATE_MODIFIED)) { if (_dmap_share_client_requested (mb->bits, SONG_DATE_MODIFIED)) {
gint32 mtime; gint32 mtime = 0;
g_object_get (record, "mtime", &mtime, NULL); g_object_get (record, "mtime", &mtime, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDM, mtime); dmap_structure_add (mlit, DMAP_CC_ASDM, mtime);
} }
if (_dmap_share_client_requested (mb->bits, SONG_DISC_COUNT)) if (_dmap_share_client_requested (mb->bits, SONG_DISC_COUNT))
dmap_structure_add (mlit, DMAP_CC_ASDC, (gint32) 0); dmap_structure_add (mlit, DMAP_CC_ASDC, (gint32) 0);
if (_dmap_share_client_requested (mb->bits, SONG_DISC_NUMBER)) { if (_dmap_share_client_requested (mb->bits, SONG_DISC_NUMBER)) {
gint32 disc; gint32 disc = 0;
g_object_get (record, "disc", &disc, NULL); g_object_get (record, "disc", &disc, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDN, disc); dmap_structure_add (mlit, DMAP_CC_ASDN, disc);
} }
...@@ -630,7 +630,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -630,7 +630,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_EQ_PRESET)) if (_dmap_share_client_requested (mb->bits, SONG_EQ_PRESET))
dmap_structure_add (mlit, DMAP_CC_ASEQ, ""); dmap_structure_add (mlit, DMAP_CC_ASEQ, "");
if (_dmap_share_client_requested (mb->bits, SONG_FORMAT)) { if (_dmap_share_client_requested (mb->bits, SONG_FORMAT)) {
gchar *format; gchar *format = NULL;
if (transcode_format) if (transcode_format)
format = g_strdup (transcode_format); format = g_strdup (transcode_format);
else else
...@@ -642,7 +642,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -642,7 +642,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Format requested but not available"); g_warning ("Format requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) { if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) {
gchar *genre; gchar *genre = NULL;
g_object_get (record, "songgenre", &genre, NULL); g_object_get (record, "songgenre", &genre, NULL);
if (genre) { if (genre) {
dmap_structure_add (mlit, DMAP_CC_ASGN, genre); dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
...@@ -657,7 +657,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -657,7 +657,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_SAMPLE_RATE)) if (_dmap_share_client_requested (mb->bits, SONG_SAMPLE_RATE))
dmap_structure_add (mlit, DMAP_CC_ASSR, 0); dmap_structure_add (mlit, DMAP_CC_ASSR, 0);
if (_dmap_share_client_requested (mb->bits, SONG_SIZE)) { if (_dmap_share_client_requested (mb->bits, SONG_SIZE)) {
guint64 filesize; guint64 filesize = 0;
g_object_get (record, "filesize", &filesize, NULL); g_object_get (record, "filesize", &filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_ASSZ, (gint32) filesize); dmap_structure_add (mlit, DMAP_CC_ASSZ, (gint32) filesize);
} }
...@@ -673,27 +673,27 @@ add_entry_to_mlcl (gpointer id, ...@@ -673,27 +673,27 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_TRACK_COUNT)) if (_dmap_share_client_requested (mb->bits, SONG_TRACK_COUNT))
dmap_structure_add (mlit, DMAP_CC_ASTC, 0); dmap_structure_add (mlit, DMAP_CC_ASTC, 0);
if (_dmap_share_client_requested (mb->bits, SONG_TRACK_NUMBER)) { if (_dmap_share_client_requested (mb->bits, SONG_TRACK_NUMBER)) {
gint32 track; gint32 track = 0;
g_object_get (record, "track", &track, NULL); g_object_get (record, "track", &track, NULL);
dmap_structure_add (mlit, DMAP_CC_ASTN, track); dmap_structure_add (mlit, DMAP_CC_ASTN, track);
} }
if (_dmap_share_client_requested (mb->bits, SONG_USER_RATING)) { if (_dmap_share_client_requested (mb->bits, SONG_USER_RATING)) {
gint32 rating; gint32 rating = 0;
g_object_get (record, "rating", &rating, NULL); g_object_get (record, "rating", &rating, NULL);
dmap_structure_add (mlit, DMAP_CC_ASUR, rating); dmap_structure_add (mlit, DMAP_CC_ASUR, rating);
} }
if (_dmap_share_client_requested (mb->bits, SONG_YEAR)) { if (_dmap_share_client_requested (mb->bits, SONG_YEAR)) {
gint32 year; gint32 year = 0;
g_object_get (record, "year", &year, NULL); g_object_get (record, "year", &year, NULL);
dmap_structure_add (mlit, DMAP_CC_ASYR, year); dmap_structure_add (mlit, DMAP_CC_ASYR, year);
} }
if (_dmap_share_client_requested (mb->bits, SONG_HAS_VIDEO)) { 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); g_object_get (record, "has-video", &has_video, NULL);
dmap_structure_add (mlit, DMAP_CC_AEHV, has_video); dmap_structure_add (mlit, DMAP_CC_AEHV, has_video);
} }
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ARTIST)) { 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); g_object_get (record, "sort-artist", &sort_artist, NULL);
if (sort_artist) if (sort_artist)
dmap_structure_add (mlit, DMAP_CC_ASSA, sort_artist); dmap_structure_add (mlit, DMAP_CC_ASSA, sort_artist);
...@@ -701,7 +701,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -701,7 +701,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Sort artist requested but not available"); g_warning ("Sort artist requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ALBUM)) { 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); g_object_get (record, "sort-album", &sort_album, NULL);
if (sort_album) if (sort_album)
dmap_structure_add (mlit, DMAP_CC_ASSU, sort_album); dmap_structure_add (mlit, DMAP_CC_ASSU, sort_album);
...@@ -709,7 +709,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -709,7 +709,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Sort album requested but not available"); g_warning ("Sort album requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, SONG_MEDIAKIND)) { if (_dmap_share_client_requested (mb->bits, SONG_MEDIAKIND)) {
gint mediakind; gint mediakind = 0;
g_object_get (record, "mediakind", &mediakind, NULL); g_object_get (record, "mediakind", &mediakind, NULL);
dmap_structure_add (mlit, DMAP_CC_AEMK, mediakind); dmap_structure_add (mlit, DMAP_CC_AEMK, mediakind);
} }
......
...@@ -361,7 +361,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -361,7 +361,7 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, ITEM_ID)) if (_dmap_share_client_requested (mb->bits, ITEM_ID))
dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id)); dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) { if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
gchar *filename; gchar *filename = NULL;
g_object_get (record, "filename", &filename, NULL); g_object_get (record, "filename", &filename, NULL);
if (filename) { if (filename) {
dmap_structure_add (mlit, DMAP_CC_MINM, filename); dmap_structure_add (mlit, DMAP_CC_MINM, filename);
...@@ -374,7 +374,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -374,7 +374,7 @@ add_entry_to_mlcl (gpointer id,
if (TRUE) { if (TRUE) {
/* dpap-sharp claims iPhoto '08 will not show thumbnails without PASP /* dpap-sharp claims iPhoto '08 will not show thumbnails without PASP
* and this does seem to be the case when testing. */ * 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); g_object_get (record, "aspect-ratio", &aspect_ratio, NULL);
if (aspect_ratio) { if (aspect_ratio) {
dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio); dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio);
...@@ -383,12 +383,12 @@ add_entry_to_mlcl (gpointer id, ...@@ -383,12 +383,12 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Aspect ratio requested but not available"); g_warning ("Aspect ratio requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_CREATIONDATE)) { 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); g_object_get (record, "creation-date", &creation_date, NULL);
dmap_structure_add (mlit, DMAP_CC_PICD, creation_date); dmap_structure_add (mlit, DMAP_CC_PICD, creation_date);
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILENAME)) { if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILENAME)) {
gchar *filename; gchar *filename = NULL;
g_object_get (record, "filename", &filename, NULL); g_object_get (record, "filename", &filename, NULL);
if (filename) { if (filename) {
dmap_structure_add (mlit, DMAP_CC_PIMF, filename); dmap_structure_add (mlit, DMAP_CC_PIMF, filename);
...@@ -397,7 +397,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -397,7 +397,7 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Filename requested but not available"); g_warning ("Filename requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFORMAT)) { if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFORMAT)) {
gchar *format; gchar *format = NULL;
g_object_get (record, "format", &format, NULL); g_object_get (record, "format", &format, NULL);
if (format) { if (format) {
dmap_structure_add (mlit, DMAP_CC_PFMT, format); dmap_structure_add (mlit, DMAP_CC_PFMT, format);
...@@ -406,32 +406,32 @@ add_entry_to_mlcl (gpointer id, ...@@ -406,32 +406,32 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Format requested but not available"); g_warning ("Format requested but not available");
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILESIZE)) { if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILESIZE)) {
gint filesize; gint filesize = 0;
g_object_get (record, "filesize", &filesize, NULL); g_object_get (record, "filesize", &filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_PIFS, filesize); dmap_structure_add (mlit, DMAP_CC_PIFS, filesize);
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGELARGEFILESIZE)) { 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); g_object_get (record, "large-filesize", &large_filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_PLSZ, large_filesize); dmap_structure_add (mlit, DMAP_CC_PLSZ, large_filesize);
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEPIXELHEIGHT)) { 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); g_object_get (record, "pixel-height", &pixel_height, NULL);
dmap_structure_add (mlit, DMAP_CC_PHGT, pixel_height); dmap_structure_add (mlit, DMAP_CC_PHGT, pixel_height);
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEPIXELWIDTH)) { 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); g_object_get (record, "pixel-width", &pixel_width, NULL);
dmap_structure_add (mlit, DMAP_CC_PWTH, pixel_width); dmap_structure_add (mlit, DMAP_CC_PWTH, pixel_width);
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGERATING)) { if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGERATING)) {
gint rating; gint rating = 0;
g_object_get (record, "rating", &rating, NULL); g_object_get (record, "rating", &rating, NULL);
dmap_structure_add (mlit, DMAP_CC_PRAT, rating); dmap_structure_add (mlit, DMAP_CC_PRAT, rating);
} }
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGECOMMENTS)) { if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGECOMMENTS)) {
gchar *comments; gchar *comments = NULL;
g_object_get (record, "comments", &comments, NULL); g_object_get (record, "comments", &comments, NULL);
if (comments) { if (comments) {
dmap_structure_add (mlit, DMAP_CC_PCMT, comments); dmap_structure_add (mlit, DMAP_CC_PCMT, comments);
...@@ -447,7 +447,7 @@ add_entry_to_mlcl (gpointer id, ...@@ -447,7 +447,7 @@ add_entry_to_mlcl (gpointer id,
g_object_get (record, "filesize", &size, NULL); g_object_get (record, "filesize", &size, NULL);
} else { } else {
/* Should be PHOTO_HIRES */ /* Should be PHOTO_HIRES */
char *location; char *location = NULL;
g_object_get (record, "location", &location, NULL); g_object_get (record, "location", &location, NULL);
if (mapped_file) { if (mapped_file) {
/* Free any previously mapped image */ /* Free any previously mapped image */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment