Commit Diff


commit - 9714e35f37d138ec783d6814c4becce70454ea7f
commit + 4d5554053935da6602bbd91a680c643f7c3b7dca
blob - 19f400aad58526650990b88d2d48d7f7dd8aa352
blob + bd382be327143898f14dd9a8b3486dabfbf13f14
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -136,8 +136,7 @@ got_fileindex_entry_alloc(struct got_fileindex_entry *
 		return err;
 	}
 
-	(*entry)->path_len = strlen(relpath);
-	len = (*entry)->path_len;
+	len = strlen(relpath);
 	if (len > GOT_FILEIDX_F_PATH_LEN)
 		len = GOT_FILEIDX_F_PATH_LEN;
 	(*entry)->flags |= len;
@@ -151,6 +150,12 @@ got_fileindex_entry_free(struct got_fileindex_entry *e
 {
 	free(entry->path);
 	free(entry);
+}
+
+size_t
+got_fileindex_entry_path_len(const struct got_fileindex_entry *ie)
+{
+	return (size_t)(ie->flags & GOT_FILEIDX_F_PATH_LEN);
 }
 
 int
@@ -207,7 +212,7 @@ got_fileindex_entry_get(struct got_fileindex *fileinde
 	struct got_fileindex_entry key;
 	memset(&key, 0, sizeof(key));
 	key.path = (char *)path;
-	key.path_len = path_len;
+	key.flags = (path_len & GOT_FILEIDX_F_PATH_LEN);
 	return RB_FIND(got_fileindex_tree, &fileindex->entries, &key);
 }
 
@@ -548,8 +553,6 @@ read_fileindex_entry(struct got_fileindex_entry **entr
 		goto done;
 
 	err = read_fileindex_path(&entry->path, ctx, infile);
-	if (err == NULL)
-		entry->path_len = strlen(entry->path);
 done:
 	if (err)
 		got_fileindex_entry_free(entry);
@@ -698,7 +701,7 @@ diff_fileindex_tree(struct got_fileindex *fileindex,
 				break;
 			}
 			cmp = got_path_cmp((*ie)->path, te_path,
-			    (*ie)->path_len, strlen(te_path));
+			    got_fileindex_entry_path_len(*ie), strlen(te_path));
 			free(te_path);
 			if (cmp == 0) {
 				if (got_path_is_child((*ie)->path, path,
@@ -918,7 +921,8 @@ diff_fileindex_dir(struct got_fileindex *fileindex,
 				break;
 			}
 			cmp = got_path_cmp((*ie)->path, de_path,
-			    (*ie)->path_len, strlen(path) + 1 + de->d_namlen);
+			    got_fileindex_entry_path_len(*ie),
+			    strlen(path) + 1 + de->d_namlen);
 			free(de_path);
 			if (cmp == 0) {
 				err = cb->diff_old_new(cb_arg, *ie, de, path);
blob - f9c79663bb1df89f3299e244b6725836ffdceb48
blob + 6e547e27cd633c27c0648309c2fc70ba53f8f1f3
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
@@ -55,18 +55,21 @@ struct got_fileindex_entry {
 	 * Variable length, and NUL-padded to a multiple of 8 on disk.
 	 */
 	char *path;
-	size_t path_len; /* strlen(path) -- kept in memory only! */
 };
 
 struct got_fileindex;
 
 RB_HEAD(got_fileindex_tree, got_fileindex_entry);
 
+size_t got_fileindex_entry_path_len(const struct got_fileindex_entry *);
+
 static inline int
 got_fileindex_cmp(const struct got_fileindex_entry *e1,
     const struct got_fileindex_entry *e2)
 {
-	return got_path_cmp(e1->path, e2->path, e1->path_len, e2->path_len);
+	return got_path_cmp(e1->path, e2->path,
+	    got_fileindex_entry_path_len(e1),
+	    got_fileindex_entry_path_len(e2));
 }
 
 RB_PROTOTYPE(got_fileindex_tree, got_fileindex_entry, entry, got_fileindex_cmp);
@@ -90,6 +93,7 @@ const struct got_error *got_fileindex_entry_update(str
 const struct got_error *got_fileindex_entry_alloc(struct got_fileindex_entry **,
     const char *, const char *, uint8_t *, uint8_t *);
 void got_fileindex_entry_free(struct got_fileindex_entry *);
+
 struct got_fileindex *got_fileindex_alloc(void);
 void got_fileindex_free(struct got_fileindex *);
 const struct got_error *got_fileindex_write(struct got_fileindex *, FILE *);