On Wed, Aug 05, 2026 at 03:29:21PM +0200, Toon Claes wrote:
Show 38 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/odb.c b/odb.c
> > index cf6e7938c0..b463afa072 100644
> > --- a/odb.c
> > +++ b/odb.c
> > @@ -1004,26 +1004,30 @@ int odb_write_object_stream(struct object_database *odb,
> > }
> >
> > struct object_database *odb_new(struct repository *repo,
> > - const char *primary_source,
> > - const char *secondary_sources)
> > + enum odb_new_flags flags)
> > {
> > - struct object_database *o = xmalloc(sizeof(*o));
> > - char *to_free = NULL;
> > + char *primary_source = NULL, *secondary_sources = NULL;
> > + struct object_database *o;
> >
> > - memset(o, 0, sizeof(*o));
> > + CALLOC_ARRAY(o, 1);
> > o->repo = repo;
> > pthread_mutex_init(&o->replace_mutex, NULL);
> > string_list_init_dup(&o->submodule_source_paths);
> >
> > + if (flags & ODB_NEW_HONOR_ENV) {
> > + primary_source = xstrdup_or_null(getenv(DB_ENVIRONMENT));
> > + secondary_sources = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));
> > + }
> > if (!primary_source)
> > - primary_source = to_free = xstrfmt("%s/objects", repo->commondir);
> > + primary_source = xstrfmt("%s/objects", repo->commondir);
> > +
> > o->sources = odb_source_new(o, primary_source, true);
> > o->sources_tail = &o->sources->next;
> > o->alternate_db = xstrdup_or_null(secondary_sources);
>
> I'd say this xstrdup_or_null() is not needed no more, and so is the
> free() of that variable below.