xserver: Branch 'master' - 2 commits
Peter Hutterer
whot at kemper.freedesktop.org
Sun Apr 19 05:22:47 PDT 2009
include/xkbsrv.h | 5 +++++
os/log.c | 22 ++++++----------------
xkb/xkbInit.c | 30 +++++++++++++++++++-----------
3 files changed, 30 insertions(+), 27 deletions(-)
New commits:
commit 0e0642ee9466d3268476d0084a83a9d93a4aa555
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Apr 16 16:17:07 2009 +1000
os: don't malloc memory in LogVMessageVerb.
LogVWrite is limited to a buffer size of 1024, so we don't loose anything here
by truncating. This way we can use LogVMessageVerb (and xf86Msg and friends)
during signal handlers with the normal message types.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Acked-by: Alan Coopersmith <alan.coopersmith at sun.com>
diff --git a/os/log.c b/os/log.c
index 3961b0b..8108890 100644
--- a/os/log.c
+++ b/os/log.c
@@ -316,7 +316,7 @@ void
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
{
const char *s = X_UNKNOWN_STRING;
- char *tmpBuf = NULL;
+ char tmpBuf[1024];
/* Ignore verbosity for X_ERROR */
if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
@@ -358,21 +358,11 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
break;
}
- /*
- * Prefix the format string with the message type. We do it this way
- * so that LogVWrite() is only called once per message.
- */
- if (s) {
- tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1);
- /* Silently return if malloc fails here. */
- if (!tmpBuf)
- return;
- sprintf(tmpBuf, "%s ", s);
- strcat(tmpBuf, format);
- LogVWrite(verb, tmpBuf, args);
- free(tmpBuf);
- } else
- LogVWrite(verb, format, args);
+ /* if s is not NULL we need a space before format */
+ snprintf(tmpBuf, sizeof(tmpBuf), "%s%s%s", s ? s : "",
+ s ? " " : "",
+ format);
+ LogVWrite(verb, tmpBuf, args);
}
}
commit 62d2fb68638e9f2aa3c1d72027619c4d38f5b812
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Apr 16 17:06:33 2009 +1000
xkb: Add XkbFreeRMLVOSet helper function.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Acked-by: Dan Nicholson <dbn.lists at gmail.com>
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 8a81431..df33085 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -858,6 +858,11 @@ extern _X_EXPORT void XkbGetRulesDflts(
XkbRMLVOSet * /* rmlvo */
);
+extern _X_EXPORT void XkbFreeRMLVOSet(
+ XkbRMLVOSet * /* rmlvo */,
+ Bool /* freeRMLVO */
+);
+
extern _X_EXPORT void XkbSetRulesDflts(
XkbRMLVOSet * /* rmlvo */
);
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 9d4d9a2..5ac06fe 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -136,6 +136,24 @@ XkbGetRulesDflts(XkbRMLVOSet *rmlvo)
rmlvo->options = strdup(rmlvo->options);
}
+void
+XkbFreeRMLVOSet(XkbRMLVOSet *rmlvo, Bool freeRMLVO)
+{
+ if (!rmlvo)
+ return;
+
+ xfree(rmlvo->rules);
+ xfree(rmlvo->model);
+ xfree(rmlvo->layout);
+ xfree(rmlvo->variant);
+ xfree(rmlvo->options);
+
+ if (freeRMLVO)
+ xfree(rmlvo);
+ else
+ memset(rmlvo, 0, sizeof(XkbRMLVOSet));
+}
+
static Bool
XkbWriteRulesProp(ClientPtr client, pointer closure)
{
@@ -595,17 +613,7 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo,
XkbSetRulesDflts(rmlvo);
XkbSetRulesUsed(rmlvo);
-
- if (rmlvo_dflts.rules)
- xfree(rmlvo_dflts.rules);
- if (rmlvo_dflts.model)
- xfree(rmlvo_dflts.model);
- if (rmlvo_dflts.layout)
- xfree(rmlvo_dflts.layout);
- if (rmlvo_dflts.variant)
- xfree(rmlvo_dflts.variant);
- if (rmlvo_dflts.options)
- xfree(rmlvo_dflts.options);
+ XkbFreeRMLVOSet(&rmlvo_dflts, FALSE);
return TRUE;
More information about the xorg-commit
mailing list