# Re: \[PATCH v6 1/6\] object-file.c: release strbuf in write\_loose\_object()

- From: Junio C Hamano \<hidden\>
- Date: 2021-12-18 00:09:35 
- List: git
- Page: https://ratatoskr.run/git/2021/12/7916042
- Thread: https://ratatoskr.run/git/2021/12/7916042/t.md

```text
René Scharfe [ref] writes:

> There was no leak before.  Both strbufs are static and both functions
> they are passed to (loose_object_path() and create_tmpfile()) reset
> them first.  So while the allocated memory was not released before,
> it was reused.
>
> Not sure if making write_loose_object() allocate and release these
> buffers on every call has much of a performance impact.  The only
> reason I can think of for wanting such a change is to get rid of the
> static buffers, to allow the function to be used by concurrent
> threads.
>
> So I think either keeping the code as-is or also making the strbufs
> non-static would be better (but then discussing a possible
> performance impact in the commit message would be nice).

Makes sense.
```
