The g_malloc()/g_malloc0() versions exit/segfault if not enough memory
is available, which is not a good thing in libsigrok.
Instead, we use the g_try_malloc()/g_try_malloc0() variants, which
return NULL if not enough memory is available, so that the caller can
handle the error properly.
We should use these (internal) functions in libsigrok exclusively from
now on, i.e. no more use of glib's g_debug() etc.
These functions are only for libsigrok, the frontends use whatever
logging mechanism is suitable there.
Stuff like
./bin/sigrok-cli -i rnd.dd -a transitioncounter
would segfault (rnd.dd consists of random bytes) because device->plugin
was NULL and was being dereferenced.
Thanks Olivier Fauchon <olivier@aixmarseille.com> for reporting.
this is needed to support file loading: we want a device struct
so we can enumerate probes from the file, but there is no plugin
since the data come in from a device.