diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2015-04-14 09:42:35 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2015-04-16 17:59:18 +0200 |
commit | a5f71f084e9f32e947a04da69edb7aae96d61697 (patch) | |
tree | 03acc5d7d7bb0d35152bfc597eb788b938f09647 /nx-X11/programs/Xserver/hw/nxagent/NXglyph.c | |
parent | fad840cfe558601a8ec02414f1235824bc9f3168 (diff) | |
download | nx-libs-a5f71f084e9f32e947a04da69edb7aae96d61697.tar.gz nx-libs-a5f71f084e9f32e947a04da69edb7aae96d61697.tar.bz2 nx-libs-a5f71f084e9f32e947a04da69edb7aae96d61697.zip |
NXAGENT_UPGRADE code cleanup:
NX agent contains/ed two build trees. An old one (probably pre-3.x.y)
and a "newer" one. The "newer" code tree used to become enabled by
setting NXUpgradeAgentServer in nx-X11/config/cf/host.def to YES.
As building the NXUpgradeAgentServer has been the default for
years now, we drop all code that does not get used at build time
for NXUpgradeAgentServer == YES (i.e., the code that belongs to the
pre-3.x.y phase of NX agent).
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/NXglyph.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/NXglyph.c | 94 |
1 files changed, 82 insertions, 12 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 22483b3fd..cd65fdc0e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -1,9 +1,3 @@ -#ifdef NXAGENT_UPGRADE - -#include "X/NXglyph.c" - -#else - /**************************************************************************/ /* */ /* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ @@ -22,9 +16,9 @@ /**************************************************************************/ /* - * $XFree86: xc/programs/Xserver/render/glyph.c,v 1.6 2001/10/28 03:34:19 tsi Exp $ + * $XFree86: xc/programs/Xserver/render/glyph.c,v 1.5 2001/01/30 07:01:22 keithp Exp $ * - * Copyright © 2000 SuSE, Inc. + * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -46,6 +40,10 @@ * Author: Keith Packard, SuSE, Inc. */ +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + #include "misc.h" #include "scrnintstr.h" #include "os.h" @@ -71,6 +69,17 @@ #undef DEBUG #undef TEST +#else + +#include "picturestr.h" +#include "glyphstr.h" + +#endif + +#if HAVE_STDINT_H +#include <stdint.h> +#elif !defined(UINT32_MAX) +#define UINT32_MAX 0xffffffffU #endif /* @@ -123,6 +132,50 @@ FindGlyphHashSet (CARD32 filled) return 0; } +static int _GlyphSetPrivateAllocateIndex = 0; + +int +AllocateGlyphSetPrivateIndex (void) +{ + return _GlyphSetPrivateAllocateIndex++; +} + +void +ResetGlyphSetPrivateIndex (void) +{ + _GlyphSetPrivateAllocateIndex = 0; +} + +Bool +_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr) +{ + pointer *new; + + if (n > glyphSet->maxPrivate) { + if (glyphSet->devPrivates && + glyphSet->devPrivates != (pointer)(&glyphSet[1])) { + new = (pointer *) xrealloc (glyphSet->devPrivates, + (n + 1) * sizeof (pointer)); + if (!new) + return FALSE; + } else { + new = (pointer *) xalloc ((n + 1) * sizeof (pointer)); + if (!new) + return FALSE; + if (glyphSet->devPrivates) + memcpy (new, + glyphSet->devPrivates, + (glyphSet->maxPrivate + 1) * sizeof (pointer)); + } + glyphSet->devPrivates = new; + /* Zero out new, uninitialize privates */ + while (++glyphSet->maxPrivate < n) + glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0; + } + glyphSet->devPrivates[n] = ptr; + return TRUE; +} + Bool GlyphInit (ScreenPtr pScreen) { @@ -359,8 +412,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) { int size; GlyphPtr glyph; - - size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]); + size_t padded_width; + + padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]); + if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height) + return 0; + size = gi->height * padded_width; glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec)); if (!glyph) return 0; @@ -456,15 +513,24 @@ GlyphSetPtr AllocateGlyphSet (int fdepth, PictFormatPtr format) { GlyphSetPtr glyphSet; + int size; if (!globalGlyphs[fdepth].hashSet) { if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0])) return FALSE; } - glyphSet = xalloc (sizeof (GlyphSetRec)); + + size = (sizeof (GlyphSetRec) + + (sizeof (pointer) * _GlyphSetPrivateAllocateIndex)); + glyphSet = xalloc (size); if (!glyphSet) return FALSE; + bzero((char *)glyphSet, size); + glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1; + if (_GlyphSetPrivateAllocateIndex) + glyphSet->devPrivates = (pointer)(&glyphSet[1]); + if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0])) { xfree (glyphSet); @@ -503,9 +569,13 @@ FreeGlyphSet (pointer value, else ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE); xfree (table); + + if (glyphSet->devPrivates && + glyphSet->devPrivates != (pointer)(&glyphSet[1])) + xfree(glyphSet->devPrivates); + xfree (glyphSet); } return Success; } -#endif /* #ifdef NXAGENT_UPGRADE */ |