Date:2015-04-25 15:26:50 (5 years 3 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
414414
415415#ifdef HAVE_LIBOPK
416416    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());
425418        if (!opk) {
426419            WARNING("Unable to open OPK to read manual\n");
427420            return;
428421        }
429422
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);
431427        if (err < 0) {
432            WARNING("Unable to read manual from OPK\n");
428            WARNING("Unable to extract manual from OPK\n");
433429            return;
434430        }
435        opk_close(opk);
436
437        ptr = (char *) buf;
438        string str(ptr, len);
431        string str((char *) buf, len);
439432        free(buf);
440433
441434        if (manual.substr(manual.size()-8,8)==".man.txt") {

Archive Download the corresponding diff file



interactive