gnokii-users
[Top][All Lists]
Advanced

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

Re: g_malloc / g_strdup in xgnokii_lowlevel.c


From: Daniele Forsi
Subject: Re: g_malloc / g_strdup in xgnokii_lowlevel.c
Date: Tue, 21 Feb 2006 11:30:27 +0100
User-agent: Mozilla Thunderbird 1.5 (X11/20051201)

Pawel Kot wrote:

>>         phoneMonitor.phone.version = g_strdup(gdat.revision);
>>         phoneMonitor.phone.revision = g_strdup(gdat.revision);

> Agree. Seems unneeded.

and so I removed the two and two more, then it seems that the logic behind the assignment to phoneMonitor.phone.version is broken since it is a duplicate of revision in the first place (see my first post quoted above!).

Below is my proposed change, deleting the g_malloc()'s and adding a g_strdup() to copy the string such as "NHM-6" as "version", so the options dialog is ok (it has max length 7 for configDialogData.phone.version hinting that a short string like that was expected) and the debug lines print

Version: NHM-6
Model: 3330
IMEI: 350...
Revision: SW 04.30, HW 0911

else they would print

Version: SW 04.30, HW 0911
Model: 3330
IMEI: 350...
Revision: SW 04.30, HW 0911

My question: is "NHM-6" useful as version? I think so, and this is the patch

Index: xgnokii/xgnokii_lowlevel.c
===================================================================
RCS file: /sources/gnokii/gnokii/xgnokii/xgnokii_lowlevel.c,v
retrieving revision 1.91
diff -p -1 -u -r1.91 xgnokii_lowlevel.c
--- xgnokii/xgnokii_lowlevel.c    15 Jan 2006 15:13:27 -0000    1.91
+++ xgnokii/xgnokii_lowlevel.c    21 Feb 2006 00:01:39 -0000
@@ -163,3 +163,3 @@ static gn_error InitModelInf(void)
     if (error != GN_ERR_NONE) return error;
-    phoneMonitor.phone.version = g_malloc(sizeof(gdat.model));
+    phoneMonitor.phone.version = g_strdup(gdat.model);
     phoneMonitor.phone.model = gn_model_get(gdat.model);
@@ -174,5 +174,2 @@ static gn_error InitModelInf(void)
     if (error != GN_ERR_NONE) return error;
-    phoneMonitor.phone.version = g_malloc(sizeof(gdat.revision));
-    phoneMonitor.phone.revision = g_malloc(sizeof(gdat.revision));
-    phoneMonitor.phone.version = g_strdup(gdat.revision);
     phoneMonitor.phone.revision = g_strdup(gdat.revision);
@@ -184,3 +181,2 @@ static gn_error InitModelInf(void)
     if (error != GN_ERR_NONE) return error;
-    phoneMonitor.phone.imei = g_malloc(sizeof(gdat.imei));
     phoneMonitor.phone.imei = g_strdup(gdat.imei);

--
Daniele




reply via email to

[Prev in Thread] Current Thread [Next in Thread]