Use std::list to store Behavior objects
There's a bug about behavior being null. It's not clear how it gets
there, but before this CL, there was a custom implementation of linked
list to store the behaviours. Instead of implementing a
custom linked list, let's switch over to std::list to remove the
possibility of this bug.
Bug: 238626341
Test: atest libinput_tests inputflinger_tests KeyCharacterMapTest
Change-Id: I98e20de7d40b74e4af085cdafb68f867e6ebfe19
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h
index 585ea3c..1c9a5ea 100644
--- a/include/input/KeyCharacterMap.h
+++ b/include/input/KeyCharacterMap.h
@@ -18,6 +18,7 @@
#define _LIBINPUT_KEY_CHARACTER_MAP_H
#include <stdint.h>
+#include <list>
#ifdef __linux__
#include <binder/IBinder.h>
@@ -152,29 +153,22 @@
private:
struct Behavior {
- Behavior();
- Behavior(const Behavior& other);
-
- /* The next behavior in the list, or NULL if none. */
- Behavior* next;
-
/* The meta key modifiers for this behavior. */
- int32_t metaState;
+ int32_t metaState = 0;
/* The character to insert. */
- char16_t character;
+ char16_t character = 0;
/* The fallback keycode if the key is not handled. */
- int32_t fallbackKeyCode;
+ int32_t fallbackKeyCode = 0;
/* The replacement keycode if the key has to be replaced outright. */
- int32_t replacementKeyCode;
+ int32_t replacementKeyCode = 0;
};
struct Key {
Key();
Key(const Key& other);
- ~Key();
/* The single character label printed on the key, or 0 if none. */
char16_t label;
@@ -184,7 +178,7 @@
/* The list of key behaviors sorted from most specific to least specific
* meta key binding. */
- Behavior* firstBehavior;
+ std::list<Behavior> behaviors;
};
class Parser {