Re: Request to add *-resize! functions for contiguous mutable data structures.

2021-08-09 Thread Maxime Devos
Vijay Marupudi schreef op zo 08-08-2021 om 23:02 [-0500]:
> Thank you for your responses Taylan and Maxime!
> 
> My initial reaction to the concern about multithreaded code is similar
> to Taylan. I'm not sure if Guile has multithreading concepts built into
> the compiler. If so, one can only check the length again after a mutex.
> 
> Appreciate the malloc, realloc, and free FFI solution. Ideally I
> wouldn't have to do that, but it does work. I have to manually free it
> though.

You can avoid explicit free by using GC_MALLOC_ATOMIC and GC_REALLOC from
bdw-gc (the C library Guile uses for garbage collection) instead of malloc
and realloc, see .

Greetings,
Maxme.


signature.asc
Description: This is a digitally signed message part


Re: Request to add *-resize! functions for contiguous mutable data structures.

2021-08-09 Thread Vijay Marupudi
That does help with the freeing requirement, thank you Maxime!

The request for this feature, if possible, still stands, because of
ergonomic reasons, and also I want to store Scheme strings in a vector
that can be resized.

Until then, I will make do with this and the make-vector/vector-copy
strategy.

~ Vijay

On 8/9/21 1:24 PM, Maxime Devos wrote:
> Vijay Marupudi schreef op zo 08-08-2021 om 23:02 [-0500]:
>> Thank you for your responses Taylan and Maxime!
>>
>> My initial reaction to the concern about multithreaded code is similar
>> to Taylan. I'm not sure if Guile has multithreading concepts built into
>> the compiler. If so, one can only check the length again after a mutex.
>>
>> Appreciate the malloc, realloc, and free FFI solution. Ideally I
>> wouldn't have to do that, but it does work. I have to manually free it
>> though.
> 
> You can avoid explicit free by using GC_MALLOC_ATOMIC and GC_REALLOC from
> bdw-gc (the C library Guile uses for garbage collection) instead of malloc
> and realloc, see .
> 
> Greetings,
> Maxme.
>