commit 124d755ac75e1fc3cb702e5190cea76fe8ba69e2
parent aa225a30a519cf8b92ebe07347b9a599ac14743c
Author: Henry Unite <unitehenry@gmail.com>
Date: Sun, 12 Apr 2026 01:05:10 +0000
feat: string map contains
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/strings.c b/src/strings.c
@@ -169,3 +169,16 @@ char *string_map_get(StringMap *map, char *key) {
return NULL;
}
+
+bool string_map_contains(StringMap *map, char *key) {
+ StringMapEntry *entry = map->head;
+
+ while (entry) {
+ if (strcmp(entry->key, key) == 0) {
+ return true;
+ }
+ entry = entry->next;
+ }
+
+ return false;
+}
diff --git a/src/strings.h b/src/strings.h
@@ -1,6 +1,7 @@
#ifndef STRINGS_H
#define STRINGS_H
+#include <stdbool.h>
#include <stddef.h>
typedef struct {
@@ -26,5 +27,6 @@ char *trim_whitespace(const char *str);
StringMap *string_map_create(void);
void string_map_put(StringMap *map, char *key, char *value);
char *string_map_get(StringMap *map, char *key);
+bool string_map_contains(StringMap *map, char *key);
#endif