Commit 025eb8a5503ebea0b3dffaf887ef0fd8aa5e1d23

Stefan Sperling 2019-01-08T22:26:44

avoid unnecessary strdup() in got_pathset's find_element()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/lib/pathset.c b/lib/pathset.c
index 828ea4b..9b12433 100644
--- a/lib/pathset.c
+++ b/lib/pathset.c
@@ -138,9 +138,9 @@ static struct got_pathset_element *
 find_element(struct got_pathset *set, const char *path)
 {
 	struct got_pathset_element key, *entry;
-	key.path = strdup(path);
+	key.path = (char *)path;
+	key.data = NULL;
 	entry = RB_FIND(got_pathset_tree, &set->entries, &key);
-	free(key.path);
 	return entry;
 }