GBytes is Immutable

I am trying to writing a network server using gio, gobject-introspection and gjs. I am using the Gio async calls such as g_input_stream_read_async.

I have managed to map the "void *buffer" to an array. However I do not believe this is safe because g_input_stream_read_async does not ref the buffer. If the caller does not keep a reference to the array / buffer it could be free'd before the async call returns which might write over something.

It seemed like I might be able to add a variation of g_input_stream_read_async that took a GBytes instead of a void*.

Howerver GBytes is supposed to be immutable. That kindof confuses me because I see no reason why it must be that way.

My question (and sorry it took so long to get to it) ...

Why is GBytes documented as being immutable?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]