VirtualBox

Changeset 78561 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
May 17, 2019 11:15:02 AM (6 years ago)
Author:
vboxsync
Message:

Runtime/RTShMem,tstRTShMem: Add API to delete a named shared memory object on POSIX hosts and make use of it in the testcase to cleanup any leftovers from previous runs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/shmem-posix.cpp

    r76553 r78561  
    214214
    215215
     216RTDECL(int) RTShMemDelete(const char *pszName)
     217{
     218    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     219
     220    size_t cchName = strlen(pszName);
     221    AssertReturn(cchName, VERR_INVALID_PARAMETER);
     222    AssertReturn(cchName < NAME_MAX - 1, VERR_INVALID_PARAMETER); /* account for the / we add later on. */
     223    char *psz = NULL;
     224
     225    int rc = RTStrAllocEx(&psz, cchName + 2); /* '/' + terminator */
     226    if (RT_SUCCESS(rc))
     227    {
     228        psz[0] = '/';
     229        memcpy(&psz[1], pszName, cchName + 1);
     230        if (shm_unlink(psz))
     231            rc = RTErrConvertFromErrno(errno);
     232        RTStrFree(psz);
     233    }
     234
     235    return rc;
     236}
     237
     238
    216239RTDECL(uint32_t) RTShMemRefCount(RTSHMEM hShMem)
    217240{
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