aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/mouse.c
diff options
context:
space:
mode:
authorMarvin Borner2021-02-14 17:07:29 +0100
committerMarvin Borner2021-02-14 17:07:29 +0100
commit1287f9dfe987f0456e4fb0741385d5f0278ef53b (patch)
tree64d3da484a4d186a725779f20d339432d51f441a /kernel/drivers/mouse.c
parentbc4e62f629a392e1a4cf204665e91c57f4e619b2 (diff)
Message waiting and more!
Diffstat (limited to 'kernel/drivers/mouse.c')
-rw-r--r--kernel/drivers/mouse.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c
index 1e7fd1a..6f329aa 100644
--- a/kernel/drivers/mouse.c
+++ b/kernel/drivers/mouse.c
@@ -35,8 +35,6 @@ void mouse_handler()
case 2:
mouse_byte[2] = (char)inb(0x60);
- if (event)
- free(event);
event = malloc(sizeof(*event));
event->magic = MOUSE_MAGIC;
event->diff_x = mouse_byte[1];
@@ -96,6 +94,7 @@ s32 mouse_read(void *buf, u32 offset, u32 count, struct device *dev)
struct event *e = stack_pop(queue);
memcpy(buf, (u8 *)e + offset, count);
+ free(e);
return count;
}
@@ -181,7 +180,7 @@ void mouse_install(void)
irq_install_handler(12, mouse_handler);
queue = stack_new();
- struct device *dev = malloc(sizeof(*dev));
+ struct device *dev = zalloc(sizeof(*dev));
dev->name = strdup("mouse");
dev->type = DEV_CHAR;
dev->read = mouse_read;