Archived
2
0

append -> insert

This commit is contained in:
mbattista 2021-04-11 12:38:18 +00:00
parent 58cb161bf3
commit 9386cbb2e2

View File

@ -12,9 +12,9 @@ typedef struct linked_list {
struct linked_list *next; struct linked_list *next;
} node; } node;
node *head = NULL, *last = NULL; node *head = NULL;
void insertAtLast(unsigned long value, KeyCode keycode) { void insertItem(unsigned long value, KeyCode keycode) {
node *temp_node = (node *) malloc(sizeof(node)); node *temp_node = (node *) malloc(sizeof(node));
temp_node->number = value; temp_node->number = value;
@ -22,13 +22,10 @@ void insertAtLast(unsigned long value, KeyCode keycode) {
temp_node->next = NULL; temp_node->next = NULL;
// For the 1st element // For the 1st element
if (!head) { if (head) {
head = temp_node; temp_node->next = head;
last = temp_node;
} else {
last->next = temp_node;
last = temp_node;
} }
head = temp_node;
} }
void deleteItem(unsigned long value) { void deleteItem(unsigned long value) {
@ -220,7 +217,7 @@ void XKey(unsigned long key, int down) {
return; return;
if (down) if (down)
insertAtLast(key, code); insertItem(key, code);
XTestFakeKeyEvent(display, code, down, CurrentTime); XTestFakeKeyEvent(display, code, down, CurrentTime);
XSync(display, 0); XSync(display, 0);