summaryrefslogtreecommitdiff
path: root/src/atom.c
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-08-31 18:52:26 +0300
committerRan Benita <ran234@gmail.com>2012-09-03 10:31:13 +0300
commit7aa31097bf1386238efdf200a9328580850590af (patch)
tree359f9d7501ac81268c075b6023506b453f3ac544 /src/atom.c
parent651e1dab04cc4ecb67b9e7c83d634fd34c0723b6 (diff)
downloadxorg-lib-libxkbcommon-7aa31097bf1386238efdf200a9328580850590af.tar.gz
atom: add xkb_atom_lookup
This will only lookup the string and return the atom if found; it will not intern it if not. This is useful when e.g. getting a string from the user (which may be arbitrary) and comparing against atoms. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/atom.c')
-rw-r--r--src/atom.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/atom.c b/src/atom.c
index b5521ab..66cf2cf 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -185,6 +185,21 @@ find_node_pointer(struct atom_table *table, const char *string,
return found;
}
+xkb_atom_t
+atom_lookup(struct atom_table *table, const char *string)
+{
+ struct atom_node **np;
+ unsigned int fp;
+
+ if (!string)
+ return XKB_ATOM_NONE;
+
+ if (!find_node_pointer(table, string, &np, &fp))
+ return XKB_ATOM_NONE;
+
+ return (*np)->atom;
+}
+
/*
* If steal is true, we do not strdup @string; therefore it must be
* dynamically allocated, not be free'd by the caller and not be used