aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-06-22 11:32:42 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-06-22 11:32:42 +0200
commitabf3741362f4c200945db6403fcd54df6754d4af (patch)
treeea7d12c03048fab6e0cbc7571b779c592d610512 /nx-X11/programs/Xserver/hw/nxagent/NXglyph.c
parentc0754a35755cdd4e25386abc6378e07605845948 (diff)
parentc8a5e33fcdde322f486d6c69e7e16fa346793fc9 (diff)
downloadnx-libs-abf3741362f4c200945db6403fcd54df6754d4af.tar.gz
nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.tar.bz2
nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.zip
Merge branch 'uli42-pr/various' into 3.6.x
Attributes GH PR #815: https://github.com/ArcticaProject/nx-libs/pull/815
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/NXglyph.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/NXglyph.c69
1 files changed, 62 insertions, 7 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c
index 35dcbc132..72d8242bd 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c
@@ -59,6 +59,67 @@
#endif
+GlyphRefPtr
+FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
+{
+ CARD32 elt, step, s;
+ GlyphPtr glyph;
+ GlyphRefPtr table, gr, del;
+ CARD32 tableSize = hash->hashSet->size;
+
+ table = hash->table;
+ elt = signature % tableSize;
+ step = 0;
+ del = 0;
+ for (;;)
+ {
+ gr = &table[elt];
+ s = gr->signature;
+ glyph = gr->glyph;
+ if (!glyph)
+ {
+ if (del)
+ gr = del;
+ break;
+ }
+ if (glyph == DeletedGlyph)
+ {
+ if (!del)
+ del = gr;
+ else if (gr == del)
+ break;
+ }
+#ifdef NXAGENT_SERVER
+ else if (s == signature && match && glyph->size != compare->size)
+ {
+ /*
+ * if the glyphsize is different there's no need to do a memcmp
+ * because it will surely report difference. And even worse:
+ * it will read beyond the end of glyph under some
+ * circumstances, which can be detected when compiling with
+ * -fsanitize=address.
+ */
+ }
+#endif
+ else if (s == signature &&
+ (!match ||
+ memcmp (&compare->info, &glyph->info, compare->size) == 0))
+ {
+ break;
+ }
+ if (!step)
+ {
+ step = signature % hash->hashSet->rehash;
+ if (!step)
+ step = 1;
+ }
+ elt += step;
+ if (elt >= tableSize)
+ elt -= tableSize;
+ }
+ return gr;
+}
+
void
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
{
@@ -138,12 +199,6 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
int oldSize;
CARD32 s;
- #ifdef NXAGENT_SERVER
-
- CARD32 c;
-
- #endif
-
tableEntries = hash->tableEntries + change;
hashSet = FindGlyphHashSet (tableEntries);
if (hashSet == hash->hashSet)
@@ -164,7 +219,7 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
#ifdef NXAGENT_SERVER
- c = hash->table[i].corruptedGlyph;
+ CARD32 c = hash->table[i].corruptedGlyph;
#endif