diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c index c063f8b..4dd6be4 100644 --- a/src/kernel/stringmap/stringmap.c +++ b/src/kernel/stringmap/stringmap.c @@ -27,7 +27,7 @@ } if (!currentLayer[hash >> (BITS(uintptr_t) - 4)]) { currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; - } else { + } else if (currentLayer[hash >> (BITS(uintptr_t) - 4)] != string) { free(string); } return hash; diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c index c063f8b..4dd6be4 100644 --- a/src/kernel/stringmap/stringmap.c +++ b/src/kernel/stringmap/stringmap.c @@ -27,7 +27,7 @@ } if (!currentLayer[hash >> (BITS(uintptr_t) - 4)]) { currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; - } else { + } else if (currentLayer[hash >> (BITS(uintptr_t) - 4)] != string) { free(string); } return hash; diff --git a/src/userland/keyboard/main.c b/src/userland/keyboard/main.c index 54114e5..d1e6609 100644 --- a/src/userland/keyboard/main.c +++ b/src/userland/keyboard/main.c @@ -3,7 +3,7 @@ void onKey(void *data, uint32_t dataSize) { uint32_t keyCode = ioIn(0x60, 1); - log("key!"); + log("key press detected"); } int32_t main() { diff --git a/src/kernel/stringmap/stringmap.c b/src/kernel/stringmap/stringmap.c index c063f8b..4dd6be4 100644 --- a/src/kernel/stringmap/stringmap.c +++ b/src/kernel/stringmap/stringmap.c @@ -27,7 +27,7 @@ } if (!currentLayer[hash >> (BITS(uintptr_t) - 4)]) { currentLayer[hash >> (BITS(uintptr_t) - 4)] = string; - } else { + } else if (currentLayer[hash >> (BITS(uintptr_t) - 4)] != string) { free(string); } return hash; diff --git a/src/userland/keyboard/main.c b/src/userland/keyboard/main.c index 54114e5..d1e6609 100644 --- a/src/userland/keyboard/main.c +++ b/src/userland/keyboard/main.c @@ -3,7 +3,7 @@ void onKey(void *data, uint32_t dataSize) { uint32_t keyCode = ioIn(0x60, 1); - log("key!"); + log("key press detected"); } int32_t main() { diff --git a/src/userland/log/main.c b/src/userland/log/main.c index 9f3577f..672779b 100644 --- a/src/userland/log/main.c +++ b/src/userland/log/main.c @@ -9,14 +9,23 @@ } } -char buffer[100]; - -void handleLog(uint32_t stringId, uint32_t unused) { - readString(stringId, buffer); - uint32_t length = strlen(buffer); - for (uint32_t i = 0; i < length; i++) { - writeChar(buffer[i]); +void writeString(char *string) { + for (uint32_t i = 0; string[i]; i++) { + writeChar(string[i]); } +} + +void handleLog(uint32_t stringId, uint32_t unused, uint32_t caller) { + char buffer[100]; + writeChar('['); + writeChar(' '); + readString(caller, buffer); + writeString(buffer); + writeChar(' '); + writeChar(']'); + writeChar(' '); + readString(stringId, buffer); + writeString(buffer); writeChar('\r'); writeChar('\n'); }