Re: [PATCH 09/14] hash: expose hash context functions to Rust
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 30, 2025, 21:52 UTC
- Message-ID
- <xmqqh5vg3vm4.fsf@gitster.g>
- In-Reply-To
- <aQPbsX-J4eKvRTar@fruit.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 16 quoted lines
> On 2025-10-29 at 16:32:50, Junio C Hamano wrote:
>> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>>
>> > +struct git_hash_ctx *git_hash_alloc(void)
>> > +{
>> > + return malloc(sizeof(struct git_hash_ctx));
>> > +}
>>
>> Not an objection, but this looked especially curious to me because
>> it has been customary to use xmalloc() for a thing like this. Going
>> forward, is our intention that we'd explicitly handle OOM allocation
>> failures ourselves, at least in the Rust part of the code base?
>
> No, I'll change this to use `xmalloc`. Rust handles allocation itself
> and just panics on OOM, so we will not want to handle allocation
> failures ourselves.Thanks.
And re-reading what I wrote, it does not make much sense, as we would want the integration go in both direction. I should try hard to get out of this mentality of talking about C-part and Rust-part of the system. What is allocated in one side needs to be able to go to the other side and then come back seamlessly.