Date: | 2015-04-25 15:26:50 (8 years 7 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 510d67359c9d79c2958414f2e959ff8baeab0dbb |
Message: | 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. |
Files: |
src/linkapp.cpp (1 diff) |
Change Details
src/linkapp.cpp | ||
---|---|---|
414 | 414 | |
415 | 415 | #ifdef HAVE_LIBOPK |
416 | 416 | if (isOPK) { |
417 | vector<string> readme; | |
418 | char *ptr; | |
419 | struct OPK *opk; | |
420 | int err; | |
421 | void *buf; | |
422 | size_t len; | |
423 | ||
424 | opk = opk_open(opkFile.c_str()); | |
417 | struct OPK *opk = opk_open(opkFile.c_str()); | |
425 | 418 | if (!opk) { |
426 | 419 | WARNING("Unable to open OPK to read manual\n"); |
427 | 420 | return; |
428 | 421 | } |
429 | 422 | |
430 | err = opk_extract_file(opk, manual.c_str(), &buf, &len); | |
423 | void *buf; | |
424 | size_t len; | |
425 | int err = opk_extract_file(opk, manual.c_str(), &buf, &len); | |
426 | opk_close(opk); | |
431 | 427 | if (err < 0) { |
432 | WARNING("Unable to read manual from OPK\n"); | |
428 | WARNING("Unable to extract manual from OPK\n"); | |
433 | 429 | return; |
434 | 430 | } |
435 | opk_close(opk); | |
436 | ||
437 | ptr = (char *) buf; | |
438 | string str(ptr, len); | |
431 | string str((char *) buf, len); | |
439 | 432 | free(buf); |
440 | 433 | |
441 | 434 | if (manual.substr(manual.size()-8,8)==".man.txt") { |
Branches:
install_locations
master
opkrun
packages