[gnome-desktop] Revert "Don't use fixed-length arrays for EDID"



commit 42452cada8cf1c4d7a81aded0a3ddbb5e97441de
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jun 11 13:00:32 2010 +0100

    Revert "Don't use fixed-length arrays for EDID"
    
    This reverts commit cd51db012316b571f03e7557b1159a7cbbcfcdeb.

 libgnome-desktop/edid-parse.c      |   48 ++++++------------------------------
 libgnome-desktop/edid.h            |    9 +++---
 libgnome-desktop/gnome-rr-config.c |    2 +-
 3 files changed, 13 insertions(+), 46 deletions(-)
---
diff --git a/libgnome-desktop/edid-parse.c b/libgnome-desktop/edid-parse.c
index ef00682..225778a 100644
--- a/libgnome-desktop/edid-parse.c
+++ b/libgnome-desktop/edid-parse.c
@@ -349,44 +349,27 @@ decode_standard_timings (const uchar *edid, MonitorInfo *info)
     return TRUE;
 }
 
-static char *
-decode_lf_string (const uchar *s, int n_chars, char *prev)
+static void
+decode_lf_string (const uchar *s, int n_chars, char *result)
 {
     int i;
-    char *ret, *tmp;
-
-    tmp = g_malloc0 (n_chars);
-
     for (i = 0; i < n_chars; ++i)
     {
 	if (s[i] == 0x0a)
 	{
-	    tmp[i] = '\0';
+	    *result++ = '\0';
 	    break;
 	}
 	else if (s[i] == 0x00)
 	{
 	    /* Convert embedded 0's to spaces */
-	    tmp[i] = ' ';
+	    *result++ = ' ';
 	}
 	else
 	{
-	    tmp[i] = s[i];
+	    *result++ = s[i];
 	}
     }
-
-    if (prev)
-    {
-       ret = g_strjoin(NULL, prev, tmp, NULL);
-       g_free(prev);
-       g_free(tmp);
-    }
-    else
-    {
-       ret = tmp;
-    }
-
-    return ret;
 }
 
 static void
@@ -396,16 +379,13 @@ decode_display_descriptor (const uchar *desc,
     switch (desc[0x03])
     {
     case 0xFC:
-	info->dsc_product_name = decode_lf_string (desc + 5, 13,
-                                                   info->dsc_product_name);
+	decode_lf_string (desc + 5, 13, info->dsc_product_name);
 	break;
     case 0xFF:
-	info->dsc_serial_number = decode_lf_string (desc + 5, 13,
-                                                    info->dsc_serial_number);
+	decode_lf_string (desc + 5, 13, info->dsc_serial_number);
 	break;
     case 0xFE:
-	info->dsc_string = decode_lf_string (desc + 5, 13,
-                                             info->dsc_string);
+	decode_lf_string (desc + 5, 13, info->dsc_string);
 	break;
     case 0xFD:
 	/* Range Limits */
@@ -534,18 +514,6 @@ decode_check_sum (const uchar *edid,
     info->checksum = check;
 }
 
-void
-free_edid (MonitorInfo *info)
-{
-    if (info)
-    {
-	g_free (info->dsc_product_name);
-	g_free (info->dsc_serial_number);
-	g_free (info->dsc_string);
-    }
-    g_free (info);
-}
-
 MonitorInfo *
 decode_edid (const uchar *edid)
 {
diff --git a/libgnome-desktop/edid.h b/libgnome-desktop/edid.h
index dbfd83c..55f0bfa 100644
--- a/libgnome-desktop/edid.h
+++ b/libgnome-desktop/edid.h
@@ -183,13 +183,12 @@ struct MonitorInfo
 						 */
 
     /* Optional product description */
-    char	       *dsc_serial_number;
-    char	       *dsc_product_name;
-    char	       *dsc_string;		/* Unspecified ASCII data */
+    char		dsc_serial_number[14];
+    char		dsc_product_name[14];
+    char		dsc_string[14];		/* Unspecified ASCII data */
 };
 
 MonitorInfo *decode_edid (const uchar *data);
-void         free_edid (MonitorInfo *);
-char *       make_display_name (const MonitorInfo *info);
+char *make_display_name (const MonitorInfo *info);
 
 #endif
diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index f2f8987..15ff0a3 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -502,7 +502,7 @@ gnome_rr_config_new_current (GnomeRRScreen *screen)
 	    else
 		output->display_name = make_display_name (info);
 		
-	    free_edid (info);
+	    g_free (info);
 		
 	    crtc = gnome_rr_output_get_crtc (rr_output);
 	    mode = crtc? gnome_rr_crtc_get_current_mode (crtc) : NULL;



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