summaryrefslogtreecommitdiff
path: root/src/context.c
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-10-18 22:51:10 +0200
committerRan Benita <ran234@gmail.com>2012-10-18 22:51:10 +0200
commit714e95e1445ab0d37b3970bebdd9af09d7eaf923 (patch)
treef00bcc5e57c1494ecfe7062ca98bd04c01717972 /src/context.c
parenteb748ab643ea1f35952e398fb1194d8a8fd41ec7 (diff)
downloadxorg-lib-libxkbcommon-714e95e1445ab0d37b3970bebdd9af09d7eaf923.tar.gz
Contextualize GetBuffer()
Instead storing the buffer in a non-thread-safe static array, we move it to the context. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/context.c')
-rw-r--r--src/context.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/context.c b/src/context.c
index bad4da0..53028a1 100644
--- a/src/context.c
+++ b/src/context.c
@@ -51,6 +51,10 @@ struct xkb_context {
unsigned file_id;
struct atom_table *atom_table;
+
+ /* Buffer for the *Text() functions. */
+ char text_buffer[1024];
+ size_t text_next;
};
/**
@@ -406,3 +410,20 @@ xkb_context_set_user_data(struct xkb_context *ctx, void *user_data)
{
ctx->user_data = user_data;
}
+
+char *
+xkb_context_get_buffer(struct xkb_context *ctx, size_t size)
+{
+ char *rtrn;
+
+ if (size >= sizeof(ctx->text_buffer))
+ return NULL;
+
+ if (sizeof(ctx->text_buffer) - ctx->text_next <= size)
+ ctx->text_next = 0;
+
+ rtrn = &ctx->text_buffer[ctx->text_next];
+ ctx->text_next += size;
+
+ return rtrn;
+}