From 510c5429e4c2e2f4d8752e688e9fbc008523774d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 14 Jul 2012 23:16:17 -0700 Subject: Convert ValueRec structures from unsigned long to uint32_t values 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 --- 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 d16647c..7fdea01 100644 --- a/prtype.c +++ b/prtype.c @@ -1087,7 +1087,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 3d9d99c..fa0c92a 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,16 +141,16 @@ 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; int i; 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 (i = 0; i < size; i++) value->values[i] = ILong((const unsigned char *) (def + i)); value->size = size; @@ -160,7 +160,7 @@ CreateValueRec(unsigned long key, int size, const unsigned long *def) } void -DeleteValueRec(unsigned long key) +DeleteValueRec(uint32_t key) { ValuePtr *bucket, value; @@ -175,11 +175,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; @@ -202,7 +202,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); /* ************************************************************ */ /* */ -- cgit v1.2.1