summaryrefslogtreecommitdiff
path: root/src/atom.h
Commit message (Collapse)AuthorAgeFilesLines
* atom: combine atom_intern() and atom_lookup()Ran Benita2019-11-091-4/+1
| | | | | | Use an "add" bool parameter instead. This simplifies the code a bit. Signed-off-by: Ran Benita <ran@unusedvar.com>
* parser: get rid of "stealing" atomsRan Benita2019-11-081-2/+1
| | | | | | | | | This requires (well, at least implemented by) casting away `const` which is undefined behavior, and clang started to warn about it. The micro optimization didn't save too many allocations, anyway. Signed-off-by: Ran Benita <ran@unusedvar.com>
* atom: drop {xkb_,}atom_strdupRan Benita2013-12-021-3/+0
| | | | | | | Even though in 112cccb18ad1bc877b3c4a87fa536ea085c761b5 I said it might be useful, it's not. So remove it. Signed-off-by: Ran Benita <ran234@gmail.com>
* atom: allow interning non-NUL-terminated stringsRan Benita2013-07-211-2/+3
| | | | | | We need this later. The strlen was calculated anyway, so no loss here. Signed-off-by: Ran Benita <ran234@gmail.com>
* atom: expand variable namesRan Benita2013-07-211-2/+1
| | | | | | A bit easier to understand at a glance. Signed-off-by: Ran Benita <ran234@gmail.com>
* Organize src/ and test/ headersRan Benita2012-09-161-1/+3
| | | | | | | | | | | | - Add context.h and move context-related functions from xkb-priv.h to it. - Move xkb_context definition back to context.c. - Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it. - Rename xkb-priv.h to map.h since it only contains keymap-related definitions and declarations now. - Remove unnecessary includes and some and some other small cleanups. Signed-off-by: Ran Benita <ran234@gmail.com>
* Copyright updatesDaniel Stone2012-09-121-12/+9
| | | | | | | | | | | | With Dan Nicholson's permission (via email), update his copyright and license statements to the standard X.Org boilerplate MIT license, as both myself and Ran have been using. Clean up my copyright declarations (in some cases to correct ownership), and add copyright/license statements from myself and/or Ran where appropriate. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* atom: add xkb_atom_lookupRan Benita2012-09-031-0/+3
| | | | | | | | 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>
* Some atom related optimizationsRan Benita2012-07-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | We often get a strdup'd string, just to pass it over the atom_intern and then immediately free it. But atom_intern then strdup's it again (if it's not interned already); so instead we can have the interning "steal" the memory instead of allocing a new one and freeing the old one. This is done by a new xkb_atom_steal function. It also turns out, that every time we strdup an atom, we don't actually modify it afterwards. Since we are guaranteed that the atom table will live as long as the context, we can just use xkb_atom_text instead. This removes a some more dynamic allocations. For this change we had to remove the ability to append two strings, e.g. "foo" + "bar" -> "foobar" which is only possible with string literals. This is unused and quite useless for our purposes. xkb_atom_strdup is left unused, as it may still be useful. Running rulescomp in valgrind, Before: ==7907== total heap usage: 173,698 allocs, 173,698 frees, 9,775,973 bytes allocated After: ==6348== total heap usage: 168,403 allocs, 168,403 frees, 9,732,648 bytes allocated Signed-off-by: Ran Benita <ran234@gmail.com>
* Run source tree through uncrustifyDaniel Stone2012-07-171-24/+24
| | | | | | | .uncrustify.cfg committed for future reference also, but had to manually fix up a few things: it really likes justifying struct initialisers. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Contextualize the atom tableRan Benita2012-05-091-10/+11
| | | | | | | | | | | | Each context gets its own table, i.e. interning a string in one context does not affect any other context. The existing xkb_atom_* functions are turned into wrappers around a new standalone atom_table object. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb -> keymap.]
* Make the context available for XkbcAtomTextRan Benita2012-05-091-1/+1
| | | | | | | | And rename the function to xkb_atom_text. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb -> keymap.]
* Make the context available for XkbcAtomGetStringRan Benita2012-05-091-1/+1
| | | | | | | | | | In preparation of contextualizing atom handling. Since we touch every function call, we also rename the function to xkb_atom_strdup to match xkb_atom_intern, and be more descriptive. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb -> keymap.]
* Make the context available to xkb_intern_atomRan Benita2012-05-091-1/+1
| | | | | | | | | | | In preparation of contextualizing the atom table. Since we touch every function call, also rename the function to xkb_atom_intern, to match better with the rest (which will also be renamed). Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Fixed for 'xkb' -> 'keymap'.]
* Rename XKBcommonint.h to xkb-priv.h and use itRan Benita2012-05-081-0/+48
Make the files in the src/* directory use their own header or a consilidated private header. This makes the file dependencies clearer. Also drop the pointless "xkb" file name prefix, add split a few declarations to their own files (atom.h and text.h). Signed-off-by: Ran Benita <ran234@gmail.com>