VirtualBox

Changeset 16533 in vbox


Ignore:
Timestamp:
Feb 5, 2009 5:26:22 PM (16 years ago)
Author:
vboxsync
Message:

tstLinuxC.c: Do not attempt to free output arguments on failure. Using a '_' suffix -> Utf16, this is sample code and should be extra readable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/cbinding/tstLinuxC.c

    r16500 r16533  
    301301int main(int argc, char **argv)
    302302{
    303     IVirtualBox *vbox      = NULL;
    304     ISession  *session     = NULL;
    305     PRUint32   revision    = 0;
    306     PRUnichar *version_    = NULL;
    307     PRUnichar *homefolder_ = NULL;
     303    IVirtualBox *vbox           = NULL;
     304    ISession  *session          = NULL;
     305    PRUint32   revision         = 0;
     306    PRUnichar *versionUtf16     = NULL;
     307    PRUnichar *homefolderUtf16 = NULL;
    308308    nsresult rc;     /* Result code of various function (method) calls. */
    309309
     
    353353    /* 2. Version */
    354354
    355     rc = vbox->vtbl->GetVersion(vbox, &version_);
     355    rc = vbox->vtbl->GetVersion(vbox, &versionUtf16);
    356356    if (NS_SUCCEEDED(rc))
    357357    {
    358358        char *version = NULL;
    359         VBoxUtf16ToUtf8(version_, &version);   
     359        VBoxUtf16ToUtf8(versionUtf16, &version);
    360360        printf("\tVersion: %s\n", version);
    361361        VBoxUtf8Free(version);
     362        VBoxComUnallocMem(versionUtf16);
    362363    }
    363364    else
     
    366367            argv[0], (unsigned)rc);
    367368    }
    368     VBoxComUnallocMem(version_);
    369369
    370370    /* 3. Home Folder */
    371371
    372     rc = vbox->vtbl->GetHomeFolder(vbox, &homefolder_);
     372    rc = vbox->vtbl->GetHomeFolder(vbox, &homefolderUtf16);
    373373    if (NS_SUCCEEDED(rc))
    374374    {
    375375        char *homefolder = NULL;
    376         VBoxUtf16ToUtf8(homefolder_, &homefolder);
     376        VBoxUtf16ToUtf8(homefolderUtf16, &homefolder);
    377377        printf("\tHomeFolder: %s\n", homefolder);
    378378        VBoxUtf8Free(homefolder);
     379        VBoxComUnallocMem(homefolderUtf16);
    379380    }
    380381    else
     
    383384            argv[0], (unsigned)rc);
    384385    }
    385     VBoxComUnallocMem(homefolder_);
    386386
    387387    listVMs(vbox, session);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette