[libdmapsharing] Get rid of magic number in dmap-structure.c Signed-off-by: W. Michael Petullo <mike flyn org>



commit 85055f145651f34fe22e0eec2a85ca2fe17bb19d
Author: W. Michael Petullo <mike flyn org>
Date:   Wed Jul 6 17:37:20 2011 -0500

    Get rid of magic number in dmap-structure.c
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/dmap-structure.c |    8 ++++++--
 libdmapsharing/dmap-structure.h |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/libdmapsharing/dmap-structure.c b/libdmapsharing/dmap-structure.c
index fed5899..a49c952 100644
--- a/libdmapsharing/dmap-structure.c
+++ b/libdmapsharing/dmap-structure.c
@@ -960,8 +960,12 @@ dmap_structure_print (GNode * structure)
 guint
 dmap_structure_get_size (GNode * structure)
 {
-	return ((DMAPStructureItem *) structure->data)->size +
-		8 /* FIXME: 8 = actual CC field + size field */ ;
+	DMAPStructureItem *item = (DMAPStructureItem *) structure->data;
+
+	g_assert (sizeof(cc_defs[item->content_code].string) == 4);
+	g_assert (sizeof(item->size) == 4);
+
+	return item->size + sizeof(cc_defs[item->content_code].string) + sizeof(item->size);
 }
 
 void
diff --git a/libdmapsharing/dmap-structure.h b/libdmapsharing/dmap-structure.h
index 7ca5bc2..e5d59ad 100644
--- a/libdmapsharing/dmap-structure.h
+++ b/libdmapsharing/dmap-structure.h
@@ -202,7 +202,7 @@ struct _DMAPStructureItem
 {
 	DMAPContentCode content_code;
 	GValue content;
-	guint size;
+	guint32 size;
 };
 
 GNode *dmap_structure_add (GNode * parent, DMAPContentCode cc, ...);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]