commit 94dac27cd14d635dc83d202ffa7ed21dad0de278 from: Stefan Sperling date: Fri Oct 15 09:24:56 2021 UTC raw object blocksize and read buffer were unused; remove them commit - 284e76635399152995c605f3dd640d4ac99488da commit + 94dac27cd14d635dc83d202ffa7ed21dad0de278 blob - 9550b434026142279a5994c04041865d05256b60 blob + 0115e7b78c440326e9e91c010a967b702ff8432f --- lib/got_lib_object.h +++ lib/got_lib_object.h @@ -40,8 +40,6 @@ struct got_raw_object { uint8_t *data; off_t size; size_t hdrlen; - size_t blocksize; - uint8_t *read_buf; int refcnt; /* > 0 if open and/or cached */ }; @@ -108,7 +106,7 @@ const struct got_error *got_object_read_header_privsep const struct got_error *got_object_open(struct got_object **, struct got_repository *, struct got_object_id *); const struct got_error *got_object_raw_open(struct got_raw_object **, int *, - struct got_repository *, struct got_object_id *, size_t); + struct got_repository *, struct got_object_id *); const struct got_error *got_object_raw_close(struct got_raw_object *); const struct got_error *got_object_open_by_id_str(struct got_object **, struct got_repository *, const char *); blob - 753da5d9b64bbbf173cc7d4a8207194ce7e4fbc1 blob + 5cfc0aee3892c25a4378b608302c31ca629fcabd --- lib/object.c +++ lib/object.c @@ -531,7 +531,7 @@ got_object_open(struct got_object **obj, struct got_re /* *outfd must be initialized to -1 by caller */ const struct got_error * got_object_raw_open(struct got_raw_object **obj, int *outfd, - struct got_repository *repo, struct got_object_id *id, size_t blocksize) + struct got_repository *repo, struct got_object_id *id) { const struct got_error *err = NULL; struct got_packidx *packidx = NULL; @@ -591,12 +591,6 @@ got_object_raw_open(struct got_raw_object **obj, int * goto done; } - (*obj)->read_buf = malloc(blocksize); - if ((*obj)->read_buf == NULL) { - err = got_error_from_errno("malloc"); - goto done; - } - if (outbuf) { (*obj)->f = fmemopen(outbuf, hdrlen + size, "r"); if ((*obj)->f == NULL) { @@ -626,7 +620,6 @@ got_object_raw_open(struct got_raw_object **obj, int * } (*obj)->hdrlen = hdrlen; (*obj)->size = size; - (*obj)->blocksize = blocksize; err = got_repo_cache_raw_object(repo, id, *obj); done: free(path_packfile); blob - f5a7e8d96b41d3c4b2f5699a936fa8bd32bf8118 blob + a92f3d54cd59722d9a59cd6d2c715b21bc4c1965 --- lib/object_parse.c +++ lib/object_parse.c @@ -144,7 +144,6 @@ got_object_raw_close(struct got_raw_object *obj) return NULL; } - free(obj->read_buf); if (obj->f != NULL && fclose(obj->f) == EOF && err == NULL) err = got_error_from_errno("fclose"); free(obj->data); blob - 88fa31a0498d4d53411e0111ccc521a5e0893dfb blob + 953b2e8620ccc19d5c6e3c05fe05180156f20819 --- lib/pack_create.c +++ lib/pack_create.c @@ -195,7 +195,7 @@ pick_deltas(struct got_pack_meta **meta, int nmeta, in m->obj_type == GOT_OBJ_TYPE_TAG) continue; - err = got_object_raw_open(&raw, &outfd, repo, &m->id, 8192); + err = got_object_raw_open(&raw, &outfd, repo, &m->id); if (err) goto done; m->size = raw->size; @@ -226,7 +226,7 @@ pick_deltas(struct got_pack_meta **meta, int nmeta, in continue; err = got_object_raw_open(&base_raw, &outfd, repo, - &base->id, 8192); + &base->id); if (err) goto done; err = got_deltify(&deltas, &ndeltas, @@ -1159,7 +1159,7 @@ genpack(uint8_t *pack_sha1, FILE *packfile, } m = meta[i]; m->off = ftello(packfile); - err = got_object_raw_open(&raw, &outfd, repo, &m->id, 8192); + err = got_object_raw_open(&raw, &outfd, repo, &m->id); if (err) goto done; if (m->deltas == NULL) {