summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/hashmap.c8
-rw-r--r--src/strings.c2
2 files changed, 3 insertions, 7 deletions
diff --git a/src/hashmap.c b/src/hashmap.c
index 106c65a..1e0d43e 100644
--- a/src/hashmap.c
+++ b/src/hashmap.c
@@ -93,9 +93,7 @@ HashError destroy(HashMap map)
}
// this loop never fired because I had map->size = 0 at the top. I'm an idiot.
for (int i = 0; i < map->size; i++) {
- if (map->names[i].data) {
- free(map->names[i].data);
- }
+ free(map->names[i].data);
}
free(map->keys);
free(map->status);
@@ -182,9 +180,7 @@ HashError remove_pid(pid_t pid, HashMap map)
if (res == OK) {
map->keys[idx] = 0;
map->status[idx] = 0;
- if (map->names[idx].data) {
- free(map->names[idx].data);
- }
+ free(map->names[idx].data);
struct String zeroed = {0};
map->names[idx] = zeroed;
map->used--;
diff --git a/src/strings.c b/src/strings.c
index baa433f..9df1c49 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -7,7 +7,7 @@
// new String pointers must be zeroed before being handed to this function
void init_string(struct String *str, size_t initial_capacity)
{
- if (str->data) free(str->data);
+ free(str->data);
str->data = malloc(initial_capacity);
if (str->data == NULL) {
perror("malloc() failed");