[PATCH] Move message filling into message_set_message()
Julien Danjou
julien at danjou.info
Thu Jan 29 06:37:43 PST 2009
Signed-off-by: Julien Danjou <julien at danjou.info>
---
libsn/sn-xmessages.c | 63 ++++++++++++++++++++++++++-----------------------
1 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/libsn/sn-xmessages.c b/libsn/sn-xmessages.c
index f7f6b34..f862b81 100644
--- a/libsn/sn-xmessages.c
+++ b/libsn/sn-xmessages.c
@@ -306,16 +306,44 @@ message_new(Atom type_atom_begin, Window win)
return message;
}
+static sn_bool_t
+message_set_message(SnXmessage *message, const char *src)
+{
+ const char *src_end;
+ char *dest;
+ sn_bool_t completed = FALSE;
+
+ src_end = src + 20;
+
+ message->message = sn_realloc (message->message,
+ message->allocated + (src_end - src));
+ dest = message->message + message->allocated;
+ message->allocated += (src_end - src);
+
+ /* Copy bytes, be sure we get nul byte also */
+ while (src != src_end)
+ {
+ *dest = *src;
+
+ if (*src == '\0')
+ {
+ completed = TRUE;
+ break;
+ }
+
+ ++dest;
+ ++src;
+ }
+
+ return completed;
+}
+
static SnXmessage*
add_event_to_messages (SnDisplay *display,
XEvent *xevent)
{
FindMessageData fmd;
SnXmessage *message;
- const char *src;
- const char *src_end;
- char *dest;
- sn_bool_t completed;
SnList *pending_messages;
/* We don't want screwy situations to end up causing us to allocate
@@ -350,32 +378,7 @@ add_event_to_messages (SnDisplay *display,
return NULL;
}
- src = &xevent->xclient.data.b[0];
- src_end = src + 20;
-
- message->message = sn_realloc (message->message,
- message->allocated + (src_end - src));
- dest = message->message + message->allocated;
- message->allocated += (src_end - src);
-
- completed = FALSE;
-
- /* Copy bytes, be sure we get nul byte also */
- while (src != src_end)
- {
- *dest = *src;
-
- if (*src == '\0')
- {
- completed = TRUE;
- break;
- }
-
- ++dest;
- ++src;
- }
-
- if (completed)
+ if (message_set_message (message, &xevent->xclient.data.b[0]))
{
/* Pull message out of the pending queue and return it */
sn_list_remove (pending_messages, message);
--
1.5.6.5
More information about the xdg
mailing list