Commit 7426bbfd0325eb69b703734636662a9968c36888

Stefan Sperling 2018-12-24T16:53:03

rename fileindex functions from open/close to alloc/free

diff --git a/lib/fileindex.c b/lib/fileindex.c
index 1dfa96a..e860a4d 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -28,7 +28,7 @@
 #include "got_lib_fileindex.h"
 
 const struct got_error *
-got_fileindex_entry_open(struct got_fileindex_entry **entry,
+got_fileindex_entry_alloc(struct got_fileindex_entry **entry,
     const char *ondisk_path, const char *relpath, uint8_t *blob_sha1)
 {
 	struct stat sb;
@@ -72,7 +72,7 @@ got_fileindex_entry_open(struct got_fileindex_entry **entry,
 }
 
 void
-got_fileindex_entry_close(struct got_fileindex_entry *entry)
+got_fileindex_entry_free(struct got_fileindex_entry *entry)
 {
 	free(entry->path);
 	free(entry);
@@ -89,7 +89,7 @@ got_fileindex_entry_add(struct got_fileindex *fileindex,
 }
 
 struct got_fileindex *
-got_fileindex_open(void)
+got_fileindex_alloc(void)
 {
 	struct got_fileindex *fileindex;
 
@@ -100,14 +100,14 @@ got_fileindex_open(void)
 }
 
 void
-got_fileindex_close(struct got_fileindex *fileindex)
+got_fileindex_free(struct got_fileindex *fileindex)
 {
 	struct got_fileindex_entry *entry;
 
 	while (!TAILQ_EMPTY(&fileindex->entries)) {
 		entry = TAILQ_FIRST(&fileindex->entries);
 		TAILQ_REMOVE(&fileindex->entries, entry, entry);
-		got_fileindex_entry_close(entry);
+		got_fileindex_entry_free(entry);
 		fileindex->nentries--;
 	}
 	free(fileindex);
diff --git a/lib/got_lib_fileindex.h b/lib/got_lib_fileindex.h
index d2a28dc..d0855be 100644
--- a/lib/got_lib_fileindex.h
+++ b/lib/got_lib_fileindex.h
@@ -82,11 +82,11 @@ struct got_fileindex_hdr {
 	uint8_t sha1[SHA1_DIGEST_LENGTH]; /* checksum of above on-disk data */
 };
 
-const struct got_error *got_fileindex_entry_open(struct got_fileindex_entry **,
+const struct got_error *got_fileindex_entry_alloc(struct got_fileindex_entry **,
     const char *, const char *, uint8_t *);
-void got_fileindex_entry_close(struct got_fileindex_entry *);
-struct got_fileindex *got_fileindex_open(void);
-void got_fileindex_close(struct got_fileindex *);
+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 *);
 const struct got_error *got_fileindex_entry_add(struct got_fileindex *,
     struct got_fileindex_entry *);
diff --git a/lib/worktree.c b/lib/worktree.c
index 72e810d..e296ce1 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -418,7 +418,7 @@ add_file_on_disk(struct got_worktree *worktree, struct got_fileindex *fileindex,
 
 	fsync(fd);
 
-	err = got_fileindex_entry_open(&entry, ondisk_path,
+	err = got_fileindex_entry_alloc(&entry, ondisk_path,
 	    apply_path_prefix(worktree, path), blob->id.sha1);
 	if (err)
 		goto done;
@@ -598,7 +598,7 @@ got_worktree_checkout_files(struct got_worktree *worktree,
 	if (err)
 		return err;
 
-	fileindex = got_fileindex_open();
+	fileindex = got_fileindex_alloc();
 	if (fileindex == NULL) {
 		err = got_error_from_errno();
 		goto done;
@@ -678,7 +678,7 @@ done:
 		fclose(new_index);
 	free(new_fileindex_path);
 	free(fileindex_path);
-	got_fileindex_close(fileindex);
+	got_fileindex_free(fileindex);
 	unlockerr = lock_worktree(worktree, LOCK_SH);
 	if (unlockerr && err == NULL)
 		err = unlockerr;