[Gnucash-changes] r13309 - gnucash/trunk - Phil Longstaff's patch to make the GUID length a magic number.

Derek Atkins warlord at cvs.gnucash.org
Sun Feb 19 18:41:53 EST 2006


Author: warlord
Date: 2006-02-19 18:41:53 -0500 (Sun, 19 Feb 2006)
New Revision: 13309
Trac: http://svn.gnucash.org/trac/changeset/13309

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/lib/libqof/qof/guid.c
   gnucash/trunk/lib/libqof/qof/guid.h
Log:
Phil Longstaff's patch to make the GUID length a magic number.



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-02-19 22:55:36 UTC (rev 13308)
+++ gnucash/trunk/ChangeLog	2006-02-19 23:41:53 UTC (rev 13309)
@@ -72,6 +72,9 @@
 	  Don't let users post negative invoices.  (#166864)
 	  Pop up an error dialog and prevent the post.
 
+	* lib/libqof/qof/guid.[ch]:
+	  Phil Longstaff's patch to make the GUID length a magic number.
+
 2006-02-18  Derek Atkins  <derek at ihtfp.com>
 
 	* intl-scm/xgettext.scm: remove the absolute path from filenames

Modified: gnucash/trunk/lib/libqof/qof/guid.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/guid.c	2006-02-19 22:55:36 UTC (rev 13308)
+++ gnucash/trunk/lib/libqof/qof/guid.c	2006-02-19 23:41:53 UTC (rev 13309)
@@ -126,7 +126,7 @@
     char *tmp = "NULLGUID.EMPTY.";
 
       /* 16th space for '\O' */
-	  for (i = 0; i < 16; i++)
+	  for (i = 0; i < GUID_DATA_SIZE; i++)
       null_guid.data[i] = tmp[i];
 
     null_inited = 1;
@@ -504,7 +504,7 @@
 	* is just hiding the problem, not fixing it.
 	*/
   init_from_int (433781*counter);
-  init_from_buff (guid->data, 16);
+  init_from_buff (guid->data, GUID_DATA_SIZE);
 
   if (counter == 0)
   {
@@ -540,7 +540,7 @@
 {
   size_t count;
 
-  for (count = 0; count < 16; count++, buffer += 2)
+  for (count = 0; count < GUID_DATA_SIZE; count++, buffer += 2)
     sprintf(buffer, "%02x", data[count]);
 }
 
@@ -557,7 +557,7 @@
   if (NULL == data) return FALSE;
   if (NULL == string) goto badstring;
 
-  for (count = 0; count < 16; count++)
+  for (count = 0; count < GUID_DATA_SIZE; count++)
   {
     /* check for a short string e.g. null string ... */
     if ((0==string[2*count]) || (0==string[2*count+1])) goto badstring;
@@ -583,7 +583,7 @@
   return TRUE;
 
 badstring:
-  for (count = 0; count < 16; count++)
+  for (count = 0; count < GUID_DATA_SIZE; count++)
   {
     data[count] = 0;
   }
@@ -635,7 +635,7 @@
 guid_equal(const GUID *guid_1, const GUID *guid_2)
 {
   if (guid_1 && guid_2)
-    return (memcmp(guid_1, guid_2, sizeof(GUID)) == 0);
+    return (memcmp(guid_1, guid_2, GUID_DATA_SIZE) == 0);
   else
     return FALSE;
 }
@@ -653,7 +653,7 @@
   if (guid_1 && !guid_2)
     return 1;
 
-  return memcmp (guid_1, guid_2, sizeof (GUID));
+  return memcmp (guid_1, guid_2, GUID_DATA_SIZE);
 }
 
 guint
@@ -677,7 +677,7 @@
     unsigned int i, j;
 
     for (i = 0, j = 0; i < sizeof(guint); i++, j++) {
-      if (j == 16) j = 0;
+      if (j == GUID_DATA_SIZE) j = 0;
 
       hash <<= 4;
       hash |= guid->data[j];

Modified: gnucash/trunk/lib/libqof/qof/guid.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/guid.h	2006-02-19 22:55:36 UTC (rev 13308)
+++ gnucash/trunk/lib/libqof/qof/guid.h	2006-02-19 23:41:53 UTC (rev 13309)
@@ -50,9 +50,10 @@
 */
 
 /** The type used to store guids */
+#define GUID_DATA_SIZE	16
 typedef union _GUID
 {
-  unsigned char data[16];
+  unsigned char data[GUID_DATA_SIZE];
 
   int __align_me; /* this just ensures that GUIDs are 32-bit
                    * aligned on systems that need them to be. */



More information about the gnucash-changes mailing list