summaryrefslogtreecommitdiff
path: root/src/context.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2013-07-21 17:01:20 +0300
committerRan Benita <ran234@gmail.com>2013-07-21 17:07:41 +0300
commit9e801ff782c592d89273939c1d84d8c62674f57e (patch)
tree94ada4502442fabfc8c07042dddae97e76132a58 /src/context.h
parent7e0ae4b4d5bfcebd7bf4cefcefe681ea7ecc5f61 (diff)
downloadxorg-lib-libxkbcommon-9e801ff782c592d89273939c1d84d8c62674f57e.tar.gz
ctx: adapt to the len-aware atom functions
xkb_atom_intern now takes a len parameter. Turns out though that almost all of our xkb_atom_intern calls are called on string literals, the length of which we know statically. So we add a macro to micro-optimize this case. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/context.h')
-rw-r--r--src/context.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/context.h b/src/context.h
index 7c061a0..c9bb277 100644
--- a/src/context.h
+++ b/src/context.h
@@ -43,11 +43,14 @@ xkb_atom_t
xkb_atom_lookup(struct xkb_context *ctx, const char *string);
xkb_atom_t
-xkb_atom_intern(struct xkb_context *ctx, const char *string);
+xkb_atom_intern(struct xkb_context *ctx, const char *string, size_t len);
+
+#define xkb_atom_intern_literal(ctx, literal) \
+ xkb_atom_intern((ctx), (literal), sizeof(literal) - 1)
/**
- * If @string is dynamically allocated, free'd immediately after
- * being interned, and not used afterwards, use this function
+ * If @string is dynamically allocated, NUL-terminated, free'd immediately
+ * after being interned, and not used afterwards, use this function
* instead of xkb_atom_intern to avoid some unnecessary allocations.
* The caller should not use or free the passed in string afterwards.
*/