A conversion function from GString to GByteArray would be useful.
Submitted by Diego Elio Pettenò
I'm currently working on a network server project that uses glib. Since we have a queue of packets to send to the clients, and those packets might either be binary or clear-text, it would be nice if there was a way to convert a GString to GByteArray without having to allocate and free the whole chunk of memory.
Since the memory area is allocated in the same way in both cases, it should be possible to just allocate a new basic structure, reuse the same memory pointer and copy over the length, without doing any allocation and free of the memory area (which for a server would be a sensible overhead).
I can prepare a patch if that can help getting this in a future release.