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') 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