From e61e9795c3d19b163ebea9a230c2acc718a70d79 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 25 Feb 2017 15:47:42 +0100 Subject: nxagent: half number of NameForAtom calls Because of validateString being a macro NameForAtom was called twice most of the time. Fix that by making validateString a function. Fixes ArticaProject/nx-libs#357 --- nx-X11/programs/Xserver/hw/nxagent/Agent.h | 2 -- nx-X11/programs/Xserver/hw/nxagent/Args.c | 1 + nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 4 ++++ nx-X11/programs/Xserver/hw/nxagent/Atoms.h | 2 ++ nx-X11/programs/Xserver/hw/nxagent/Client.c | 1 + nx-X11/programs/Xserver/hw/nxagent/Font.c | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Agent.h b/nx-X11/programs/Xserver/hw/nxagent/Agent.h index 8577865a2..af8b62810 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Agent.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Agent.h @@ -133,6 +133,4 @@ typedef XID KeySym64; #undef KeySym #endif /*_XSERVER64_tmp*/ -#define validateString(string) ((string) ? (string) : "(null)") - #endif /* __Agent_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 3844fe046..b4cfdc99a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -70,6 +70,7 @@ is" without express or implied warranty. #include "Handlers.h" #include "Error.h" #include "Reconnect.h" +#include "Atoms.h" /* * NX includes and definitions. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index 0784d6c2c..a0b90febd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -95,6 +95,10 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = static XErrorHandler previousErrorHandler = NULL; +const char * validateString(const char *str) { + return str ? str : "(null)"; +} + static void catchAndRedirect(Display* dpy, XErrorEvent* X) { if (X -> error_code == BadAccess && diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h index 391e06181..ceeeb88f3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h @@ -36,6 +36,8 @@ extern Atom nxagentAtoms[NXAGENT_NUMBER_OF_ATOMS]; extern Bool nxagentWMIsRunning; +extern const char * validateString(const char *); + /* * Create the required atoms internally * to the agent server. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c index 44d48d0e0..fbacbb25d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c @@ -51,6 +51,7 @@ #include "Handlers.h" #include "Events.h" #include "Drawable.h" +#include "Atoms.h" /* * Need to include this after the stub diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 97a90e176..d586c016b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -57,6 +57,7 @@ is" without express or implied warranty. #include "Reconnect.h" #include "Args.h" +#include "Atoms.h" #include "compext/Compext.h" #include -- cgit v1.2.3 From 6e8aee499ede4f8849653cdd248a6c0db5fb8b76 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 3 Mar 2017 21:44:07 +0100 Subject: nxagent: move validateString as inline func to Utils.h --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 4 ---- nx-X11/programs/Xserver/hw/nxagent/Atoms.h | 2 -- nx-X11/programs/Xserver/hw/nxagent/Client.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Font.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Rootless.c | 1 + nx-X11/programs/Xserver/hw/nxagent/Utils.h | 4 ++++ 7 files changed, 8 insertions(+), 9 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index b4cfdc99a..a6c21503a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -70,7 +70,7 @@ is" without express or implied warranty. #include "Handlers.h" #include "Error.h" #include "Reconnect.h" -#include "Atoms.h" +#include "Utils.h" /* * NX includes and definitions. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index a0b90febd..0784d6c2c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -95,10 +95,6 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = static XErrorHandler previousErrorHandler = NULL; -const char * validateString(const char *str) { - return str ? str : "(null)"; -} - static void catchAndRedirect(Display* dpy, XErrorEvent* X) { if (X -> error_code == BadAccess && diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h index ceeeb88f3..391e06181 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h @@ -36,8 +36,6 @@ extern Atom nxagentAtoms[NXAGENT_NUMBER_OF_ATOMS]; extern Bool nxagentWMIsRunning; -extern const char * validateString(const char *); - /* * Create the required atoms internally * to the agent server. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c index fbacbb25d..38d877ed7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c @@ -51,7 +51,7 @@ #include "Handlers.h" #include "Events.h" #include "Drawable.h" -#include "Atoms.h" +#include "Utils.h" /* * Need to include this after the stub diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index d586c016b..e1f12e733 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -57,7 +57,7 @@ is" without express or implied warranty. #include "Reconnect.h" #include "Args.h" -#include "Atoms.h" +#include "Utils.h" #include "compext/Compext.h" #include diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c index eabf719c4..68c6890d8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c @@ -38,6 +38,7 @@ #include "Pixmaps.h" #include "Atoms.h" #include "Trap.h" +#include "Utils.h" #include "compext/Compext.h" diff --git a/nx-X11/programs/Xserver/hw/nxagent/Utils.h b/nx-X11/programs/Xserver/hw/nxagent/Utils.h index a3cbc2e9f..8a3335424 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Utils.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Utils.h @@ -48,4 +48,8 @@ #define MAX(A, B) ( (A) > (B) ? (A) : (B) ); #endif +static inline const char * validateString(const char *str) { + return str ? str : "(null)"; +} + #endif /* __Utils_H__ */ -- cgit v1.2.3 From 06bb154df0a4d6e35885bce6a63057bd8f8636e8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 2 Mar 2017 15:38:08 +0100 Subject: replace (DE)ALLOCATE_LOCAL by malloc/free This is basically a backport of the following commits + replacing xalloc/xfree by malloc/free. Fixes ArcticaProject/nx-libs#358. commit 2761c103311a1160bc483fd0367d654733df8598 Author: Daniel Stone Date: Mon Nov 5 14:03:26 2007 +0000 OS: Remove usage of alloca Replace with heap allocations. commit 5e363500c86042c394595e1a6633581eb8fcd1bb Author: Daniel Stone Date: Mon Nov 5 14:38:28 2007 +0000 OS: Remove ALLOCATE_LOCAL from os.h Remove ALLOCATE_LOCAL_FALLBACK and DEALLOCATE_LOCAL_FALLBACK from os.h, and remove the include of Xalloca.h as well. --- nx-X11/programs/Xserver/hw/nxagent/NXdamage.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 8 ++++---- nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 8 ++++---- nx-X11/programs/Xserver/hw/nxagent/NXextension.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c | 6 +++--- nx-X11/programs/Xserver/hw/nxagent/NXrender.c | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c index e6f251a51..ad02e13a8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c @@ -112,7 +112,7 @@ damageText (DrawablePtr pDrawable, imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); - charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); + charinfo = (CharInfoPtr *) malloc(count * sizeof(CharInfoPtr)); if (!charinfo) return x; @@ -139,7 +139,7 @@ damageText (DrawablePtr pDrawable, #endif } - DEALLOCATE_LOCAL(charinfo); + free(charinfo); return x + w; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index a46434bf1..652d54479 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -274,7 +274,7 @@ Dispatch(void) #endif - clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients); + clientReady = (int *) malloc(sizeof(int) * MaxClients); if (!clientReady) return; @@ -571,7 +571,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio saveAgentState("TERMINATED"); KillAllClients(); - DEALLOCATE_LOCAL(clientReady); + free(clientReady); dispatchException &= ~DE_RESET; } @@ -653,7 +653,7 @@ ProcQueryTree(register ClientPtr client) { int curChild = 0; - childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window)); + childIDs = (Window *) malloc(numChildren * sizeof(Window)); if (!childIDs) return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) @@ -673,7 +673,7 @@ ProcQueryTree(register ClientPtr client) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); - DEALLOCATE_LOCAL(childIDs); + free(childIDs); } return(client->noClientException); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index b3d7cc9d7..1b7ce114b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -564,7 +564,7 @@ finish: reply.nFonts = nnames; reply.sequenceNumber = client->sequence; - bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2); + bufptr = bufferStart = (char *) malloc(reply.length << 2); if (!bufptr && reply.length) { SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); @@ -607,7 +607,7 @@ finish: client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); WriteToClient(client, stringLens + nnames, bufferStart); - DEALLOCATE_LOCAL(bufferStart); + free(bufferStart); bail: if (c->slept) @@ -968,7 +968,7 @@ SetDefaultFontPath(char *path) /* get enough for string, plus values -- use up commas */ len = strlen(temp_path) + 1; - nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len); + nump = cp = newpath = (unsigned char *) malloc(len); if (!newpath) { free(temp_path); return BadAlloc; @@ -991,7 +991,7 @@ SetDefaultFontPath(char *path) err = SetFontPathElements(num, newpath, &bad, TRUE); - DEALLOCATE_LOCAL(newpath); + free(newpath); free(temp_path); return err; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c index f6c63e699..9ec6be8ef 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c @@ -163,7 +163,7 @@ ProcListExtensions(ClientPtr client) total_length += strlen(extensions[i]->aliases[j]) + 1; } reply.length = (total_length + 3) >> 2; - buffer = bufptr = (char *)ALLOCATE_LOCAL(total_length); + buffer = bufptr = (char *)malloc(total_length); if (!buffer) return(BadAlloc); for (i=0; inoClientException); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c index eb92dd3bb..bcb88d42d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c @@ -566,7 +566,7 @@ int what; } } - prect = (xRectangle *)ALLOCATE_LOCAL(RegionNumRects(prgn) * + prect = (xRectangle *)malloc(RegionNumRects(prgn) * sizeof(xRectangle)); if (!prect) return; @@ -591,7 +591,7 @@ int what; pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen); if (!pGC) { - DEALLOCATE_LOCAL(prect); + free(prect); return; } /* @@ -723,7 +723,7 @@ int what; } prect -= numRects; (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect); - DEALLOCATE_LOCAL(prect); + free(prect); if (pWin->backStorage) (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 25e162445..ef288db0b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -987,7 +987,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) glyphsBase = glyphsLocal; else { - glyphsBase = (GlyphPtr *) ALLOCATE_LOCAL (nglyph * sizeof (GlyphPtr)); + glyphsBase = (GlyphPtr *) malloc (nglyph * sizeof (GlyphPtr)); if (!glyphsBase) return BadAlloc; } @@ -995,7 +995,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) listsBase = listsLocal; else { - listsBase = (GlyphListPtr) ALLOCATE_LOCAL (nlist * sizeof (GlyphListRec)); + listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec)); if (!listsBase) return BadAlloc; } @@ -1031,9 +1031,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) { client->errorValue = gs; if (glyphsBase != glyphsLocal) - DEALLOCATE_LOCAL (glyphsBase); + free (glyphsBase); if (listsBase != listsLocal) - DEALLOCATE_LOCAL (listsBase); + free (listsBase); return RenderErrBase + BadGlyphSet; } } @@ -1140,9 +1140,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) nxagentGlyphsExtents = NullBox; if (glyphsBase != glyphsLocal) - DEALLOCATE_LOCAL (glyphsBase); + free (glyphsBase); if (listsBase != listsLocal) - DEALLOCATE_LOCAL (listsBase); + free (listsBase); free(elementsBase); -- cgit v1.2.3