Use glib's API for memory allocation