If we are using C++, we might as well use scope-based memory management
for these things, cleaner and less error prone. Also removed
unnecessary gotos.
This is a port of the Android bootctrl HAL and Qualcomms GPT based
implementation for musl/glibc based systems running mainline linux
Currently it doesn't work because the gpt hdr which is read doesn't
seem to have valid data.