commit 34a842a42b1cd020ca656445c0b65e67a97bff1a from: Mark Jamsek date: Sun Sep 18 07:43:26 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 - 1681ba873c6a910d6acea91780ed16374329848b commit + 34a842a42b1cd020ca656445c0b65e67a97bff1a 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 - 90b0dd61d77d94bbc79178c6692a4fc8946ce780 blob + 51d0400aa260f449e446626d2fe0f2826612a326 --- lib/object.c +++ lib/object.c @@ -2354,11 +2354,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 - 718c6aa923bbf38b917e3e3902ff58f1920a570a blob + 5c09963ecada6bf7e25973970995b395066f23c5 --- tog/tog.c +++ tog/tog.c @@ -2362,11 +2362,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, @@ -3177,13 +3174,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,