Replaced various uses of malloc with glib versions.

glib versions abort() on failure, so checking the result for NULL is unnecessary.