VirtualBox

Ignore:
Timestamp:
Jun 6, 2017 1:42:16 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115968
Message:

RTVfsIoStrmZeroFill: Fixed wrong method test (pfnSkip instead of pfnZeroFill); use g_abRTZero64K instead of the heap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r67221 r67272  
    4242#include <iprt/semaphore.h>
    4343#include <iprt/thread.h>
     44#include <iprt/zero.h>
    4445
    4546#include "internal/file.h"
     
    30393040
    30403041    int rc;
    3041     if (pThis->pOps->pfnSkip)
     3042    if (pThis->pOps->pfnZeroFill)
    30423043    {
    30433044        RTVfsLockAcquireWrite(pThis->Base.hLock);
     
    30473048    else
    30483049    {
    3049         void *pvBuf = RTMemTmpAllocZ(_64K);
    3050         if (pvBuf)
     3050        rc = VINF_SUCCESS;
     3051        while (cb > 0)
    30513052        {
    3052             rc = VINF_SUCCESS;
    3053             while (cb > 0)
    3054             {
    3055                 size_t cbToWrite = (size_t)RT_MIN(cb, _64K);
    3056                 RTVfsLockAcquireWrite(pThis->Base.hLock);
    3057                 rc = RTVfsIoStrmWrite(hVfsIos, pvBuf, cbToWrite, true /*fBlocking*/, NULL);
    3058                 RTVfsLockReleaseWrite(pThis->Base.hLock);
    3059                 if (RT_FAILURE(rc))
    3060                     break;
    3061                 cb -= cbToWrite;
    3062             }
    3063 
    3064             RTMemTmpFree(pvBuf);
     3053            size_t cbToWrite = (size_t)RT_MIN(cb, sizeof(g_abRTZero64K));
     3054            RTVfsLockAcquireWrite(pThis->Base.hLock);
     3055            rc = RTVfsIoStrmWrite(hVfsIos, g_abRTZero64K, cbToWrite, true /*fBlocking*/, NULL);
     3056            RTVfsLockReleaseWrite(pThis->Base.hLock);
     3057            if (RT_FAILURE(rc))
     3058                break;
     3059            cb -= cbToWrite;
    30653060        }
    3066         else
    3067             rc = VERR_NO_TMP_MEMORY;
    30683061    }
    30693062    return rc;
Note: See TracChangeset for help on using the changeset viewer.

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