[PATCH:xscope 14/24] Convert ValueRec structures from unsigned long to uint32_t values

Alan Coopersmith alan.coopersmith at oracle.com
Fri Aug 31 22:17:56 PDT 2012


Used for GC struct members, which are defined in the protocol as 32-bit,
so no need to waste time and memory copying into 64-bit longs everywhere

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 print11.c |    4 ++--
 prtype.c  |    2 +-
 table11.c |   16 ++++++++--------
 x11.h     |   16 ++++++++--------
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/print11.c b/print11.c
index b96e5ac..4bf74a4 100644
--- a/print11.c
+++ b/print11.c
@@ -2205,9 +2205,9 @@ FreePixmap(FD fd, const unsigned char *buf)
     PrintField(buf, 4, 4, PIXMAP, "pixmap");
 }
 
-static const unsigned long GCDefaults[] = {
+static const uint32_t GCDefaults[] = {
     3,                          /* function GXcopy */
-    ~0,                         /* planemask */
+    (uint32_t) ~0,              /* planemask */
     0,                          /* foreground */
     1,                          /* background */
     0,                          /* line width */
diff --git a/prtype.c b/prtype.c
index 5c1f986..8d4e06f 100644
--- a/prtype.c
+++ b/prtype.c
@@ -1070,7 +1070,7 @@ DumpHexBuffer(const unsigned char *buf, long n)
 }
 
 void
-PrintValueRec(unsigned long key, unsigned long cmask, short ctype)
+PrintValueRec(uint32_t key, uint32_t cmask, short ctype)
 {
     unsigned char *values;
     struct ValueListEntry *p;
diff --git a/table11.c b/table11.c
index aaf7a48..3463173 100644
--- a/table11.c
+++ b/table11.c
@@ -128,7 +128,7 @@ ValuePtr buckets[HASH_SIZE];
 #define HASH(key)   ((key) % HASH_SIZE)
 
 ValuePtr
-GetValueRec(unsigned long key)
+GetValueRec(uint32_t key)
 {
     ValuePtr *bucket, value;
 
@@ -141,15 +141,15 @@ GetValueRec(unsigned long key)
 }
 
 void
-CreateValueRec(unsigned long key, int size, const unsigned long *def)
+CreateValueRec(uint32_t key, int size, const uint32_t *def)
 {
     ValuePtr *bucket, value;
 
     bucket = &buckets[HASH(key)];
-    value = malloc(sizeof(ValueRec) + (size * sizeof(unsigned long)));
+    value = malloc(sizeof(ValueRec) + (size * sizeof(uint32_t)));
     if (!value)
         return;
-    value->values = (unsigned long *) (value + 1);
+    value->values = (uint32_t *) (value + 1);
     for (int i = 0; i < size; i++)
         value->values[i] = ILong((const unsigned char *) (def + i));
     value->size = size;
@@ -159,7 +159,7 @@ CreateValueRec(unsigned long key, int size, const unsigned long *def)
 }
 
 void
-DeleteValueRec(unsigned long key)
+DeleteValueRec(uint32_t key)
 {
     ValuePtr *bucket, value;
 
@@ -174,11 +174,11 @@ DeleteValueRec(unsigned long key)
 }
 
 void
-SetValueRec(unsigned long key,
+SetValueRec(uint32_t key,
             const unsigned char *control,
             short clength, short ctype, const unsigned char *values)
 {
-    long cmask;
+    uint32_t cmask;
     struct ValueListEntry *p;
     ValuePtr value;
     int i;
@@ -201,7 +201,7 @@ SetValueRec(unsigned long key,
     /* the ctype is a set type, so this code is similar to PrintSET */
     for (p = TD[ctype].ValueList, i = 0; p != NULL; p = p->Next, i++) {
         if ((p->Value & cmask) != 0) {
-            memcpy(&value->values[i], values, sizeof(unsigned long));
+            memcpy(&value->values[i], values, sizeof(uint32_t));
             values += 4;
         }
     }
diff --git a/x11.h b/x11.h
index cbe0c86..6cdf270 100644
--- a/x11.h
+++ b/x11.h
@@ -512,19 +512,19 @@ extern struct ConnState *CS;
 
 typedef struct _Value {
     struct _Value *next;
-    unsigned long key;
+    uint32_t key;
     int size;
-    unsigned long *values;
+    uint32_t *values;
 } ValueRec, *ValuePtr;
 
-extern ValuePtr GetValueRec(unsigned long key);
-extern void CreateValueRec(unsigned long key, int size,
-                           const unsigned long *def);
-extern void DeleteValueRec(unsigned long key);
-extern void SetValueRec(unsigned long key, const unsigned char *control,
+extern ValuePtr GetValueRec(uint32_t key);
+extern void CreateValueRec(uint32_t key, int size,
+                           const uint32_t *def);
+extern void DeleteValueRec(uint32_t key);
+extern void SetValueRec(uint32_t key, const unsigned char *control,
                         short clength, short ctype,
                         const unsigned char *values);
-extern void PrintValueRec(unsigned long key, unsigned long cmask, short ctype);
+extern void PrintValueRec(uint32_t key, uint32_t cmask, short ctype);
 
 /* ************************************************************ */
 /*								*/
-- 
1.7.9.2



More information about the xorg-devel mailing list