commit 6f6c25d65e82e60c44877d2aa05bcbdbc48e65b3 from: Mark Jamsek via: Thomas Adam date: Sun Sep 18 07:48:21 2022 UTC drop unconventional got_object_commit_dup() routine Replace with got_object_commit_retain() to increment commit object reference counter. suggested by and ok stsp@ commit - 30e77f6ad14985d6db8d179b7ed73dc4c8cab68a commit + 6f6c25d65e82e60c44877d2aa05bcbdbc48e65b3 blob - cb676e08ed97b46d2255d4e5b79240ed2b64d571 blob + 19f043e1c43b4b21c3b19d764f34a7575df5b7a7 --- include/got_object.h +++ include/got_object.h @@ -353,5 +353,5 @@ const struct got_error *got_object_tag_create(struct g const char *, struct got_object_id *, const char *, time_t, const char *, const char *, struct got_repository *, int verbosity); -const struct got_error *got_object_commit_dup(struct got_commit_object **, - struct got_commit_object *); +/* Increment commit object reference counter. */ +void got_object_commit_retain(struct got_commit_object *); blob - f485d23a6aac717ea3e25da068cf4cea73c1de88 blob + 053eb0ba5b9cf91bc1ea8f179cf16d57da981f43 --- lib/object.c +++ lib/object.c @@ -2353,11 +2353,8 @@ done: return err; } -const struct got_error * -got_object_commit_dup(struct got_commit_object **ret, - struct got_commit_object *commit) +void +got_object_commit_retain(struct got_commit_object *commit) { - *ret = commit; commit->refcnt++; - return NULL; } blob - a2ad8c27009958805e6bb47498c2f321dd725a1a blob + ee792d2677cda12344066e20f5d3356624a8a091 --- tog/tog.c +++ tog/tog.c @@ -2367,11 +2367,8 @@ queue_commits(struct tog_log_thread_args *a) "alloc_commit_queue_entry"); break; } - - err = got_object_commit_dup(&matched->commit, - entry->commit); - if (err) - break; + matched->commit = entry->commit; + got_object_commit_retain(entry->commit); matched->idx = a->limit_commits->ncommits; TAILQ_INSERT_TAIL(&a->limit_commits->head, @@ -3182,13 +3179,8 @@ limit_log_view(struct tog_view *view) "alloc_commit_queue_entry"); break; } - - err = got_object_commit_dup(&matched->commit, - entry->commit); - if (err) { - free(matched); - return err; - } + matched->commit = entry->commit; + got_object_commit_retain(entry->commit); matched->idx = s->limit_commits.ncommits; TAILQ_INSERT_TAIL(&s->limit_commits.head,