1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-09-29 02:31:58 +03:00

Cleaned up code that loads a manual from an OPK file

Most of it is for readability only, but there is also a leak that was
plugged: opk_close() is now called if extraction fails.
This commit is contained in:
Maarten ter Huurne 2015-04-25 15:26:50 +02:00
parent 00d3c3b570
commit 510d67359c

View File

@ -414,28 +414,21 @@ void LinkApp::showManual() {
#ifdef HAVE_LIBOPK
if (isOPK) {
vector<string> readme;
char *ptr;
struct OPK *opk;
int err;
void *buf;
size_t len;
opk = opk_open(opkFile.c_str());
struct OPK *opk = opk_open(opkFile.c_str());
if (!opk) {
WARNING("Unable to open OPK to read manual\n");
return;
}
err = opk_extract_file(opk, manual.c_str(), &buf, &len);
void *buf;
size_t len;
int err = opk_extract_file(opk, manual.c_str(), &buf, &len);
opk_close(opk);
if (err < 0) {
WARNING("Unable to read manual from OPK\n");
WARNING("Unable to extract manual from OPK\n");
return;
}
opk_close(opk);
ptr = (char *) buf;
string str(ptr, len);
string str((char *) buf, len);
free(buf);
if (manual.substr(manual.size()-8,8)==".man.txt") {