Commit 5f25cc858267bf6a334ed243cd4ceaa4bcb851d6

Stefan Sperling 2019-11-26T22:43:12

remove obj->path_packfile which is unused nowadays; saves a few free() calls

diff --git a/lib/got_lib_object.h b/lib/got_lib_object.h
index f09d092..4894337 100644
--- a/lib/got_lib_object.h
+++ b/lib/got_lib_object.h
@@ -29,7 +29,6 @@ struct got_object {
 	size_t size;
 	struct got_object_id id;
 
-	char *path_packfile;	/* if packed */
 	int pack_idx;		/* if packed */
 	off_t pack_offset;	/* if packed */
 	struct got_delta_chain deltas; /* if deltified */
diff --git a/lib/object.c b/lib/object.c
index c6bef75..743225b 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -196,11 +196,6 @@ request_packed_object(struct got_object **obj, struct got_pack *pack, int idx,
 	if (err)
 		return err;
 
-	(*obj)->path_packfile = strdup(pack->path_packfile);
-	if ((*obj)->path_packfile == NULL) {
-		err = got_error_from_errno("strdup");
-		return err;
-	}
 	memcpy(&(*obj)->id, id, sizeof((*obj)->id));
 
 	return NULL;
@@ -325,7 +320,7 @@ open_packed_object(struct got_object **obj, struct got_object_id *id,
 	if (err)
 		goto done;
 
-	err = got_repo_cache_pack(NULL, repo, (*obj)->path_packfile, packidx);
+	err = got_repo_cache_pack(NULL, repo, path_packfile, packidx);
 done:
 	free(path_packfile);
 	return err;
diff --git a/lib/object_cache.c b/lib/object_cache.c
index c67ff75..db4481b 100644
--- a/lib/object_cache.c
+++ b/lib/object_cache.c
@@ -77,9 +77,6 @@ get_size_obj(struct got_object *obj)
 	size_t size = sizeof(*obj);
 	struct got_delta *delta;
 
-	if (obj->flags & GOT_OBJ_FLAG_PACKED)
-		size += strlen(obj->path_packfile);
-
 	if ((obj->flags & GOT_OBJ_FLAG_DELTIFIED) == 0)
 		return size;
 
diff --git a/lib/object_parse.c b/lib/object_parse.c
index 9124070..2c6c9f8 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -117,8 +117,6 @@ got_object_close(struct got_object *obj)
 			free(delta);
 		}
 	}
-	if (obj->flags & GOT_OBJ_FLAG_PACKED)
-		free(obj->path_packfile);
 	free(obj);
 }
 
diff --git a/lib/pack.c b/lib/pack.c
index eef27b8..76e9329 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -611,21 +611,13 @@ parse_object_type_and_size(uint8_t *type, uint64_t *size, size_t *len,
 }
 
 static const struct got_error *
-open_plain_object(struct got_object **obj, const char *path_packfile,
-    struct got_object_id *id, uint8_t type, off_t offset, size_t size, int idx)
+open_plain_object(struct got_object **obj, struct got_object_id *id,
+    uint8_t type, off_t offset, size_t size, int idx)
 {
 	*obj = calloc(1, sizeof(**obj));
 	if (*obj == NULL)
 		return got_error_from_errno("calloc");
 
-	(*obj)->path_packfile = strdup(path_packfile);
-	if ((*obj)->path_packfile == NULL) {
-		const struct got_error *err = got_error_from_errno("strdup");
-		free(*obj);
-		*obj = NULL;
-		return err;
-	}
-
 	(*obj)->type = type;
 	(*obj)->flags = GOT_OBJ_FLAG_PACKED;
 	(*obj)->pack_idx = idx;
@@ -919,12 +911,6 @@ open_delta_object(struct got_object **obj, struct got_packidx *packidx,
 
 	SIMPLEQ_INIT(&(*obj)->deltas.entries);
 	(*obj)->flags |= GOT_OBJ_FLAG_DELTIFIED;
-
-	(*obj)->path_packfile = strdup(pack->path_packfile);
-	if ((*obj)->path_packfile == NULL) {
-		err = got_error_from_errno("strdup");
-		goto done;
-	}
 	(*obj)->flags |= GOT_OBJ_FLAG_PACKED;
 	(*obj)->pack_idx = idx;
 
@@ -970,8 +956,8 @@ got_packfile_open_object(struct got_object **obj, struct got_pack *pack,
 	case GOT_OBJ_TYPE_TREE:
 	case GOT_OBJ_TYPE_BLOB:
 	case GOT_OBJ_TYPE_TAG:
-		err = open_plain_object(obj, pack->path_packfile, id, type,
-		    offset + tslen, size, idx);
+		err = open_plain_object(obj, id, type, offset + tslen,
+		    size, idx);
 		break;
 	case GOT_OBJ_TYPE_OFFSET_DELTA:
 	case GOT_OBJ_TYPE_REF_DELTA: