VirtualBox

儲存庫 vbox 的更動 37210


忽略:
時間撮記:
2011-5-25 上午09:55:16 (14 年 以前)
作者:
vboxsync
訊息:

circbuf: make the structure abstract.

位置:
trunk
檔案:
修改 3 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/iprt/circbuf.h

    r37208 r37210  
    4242RT_C_DECLS_BEGIN
    4343
    44 /** @todo r=bird: this is missing docs and magic. uXPos should be offX.
    45  *        cbBufSize should be cbBuf. */
    46 typedef struct RTCIRCBUF
    47 {
    48     /** The current read position in the buffer. */
    49     size_t uReadPos;
    50     /** The current write position in the buffer. */
    51     size_t uWritePos;
    52     /** How much space of the buffer is currently in use. */
    53     volatile size_t cbBufUsed;
    54     /** How big is the buffer. */
    55     size_t cbBufSize;
    56     /** The buffer itself. */
    57     void *pvBuf;
    58 } RTCIRCBUF;
    59 /* Pointer to a circular buffer structure */
    60 typedef RTCIRCBUF* PRTCIRCBUF;
     44/** Pointer to a circular buffer (abstract). */
     45typedef struct RTCIRCBUF *PRTCIRCBUF;
    6146
    6247/**
  • trunk/src/VBox/Runtime/common/misc/circbuf.cpp

    r37209 r37210  
    3636
    3737
     38/*******************************************************************************
     39*   Structures and Typedefs                                                    *
     40*******************************************************************************/
     41/** @todo r=bird: this is missing docs and magic. uXPos should be offX.
     42 *        cbBufSize should be cbBuf. */
     43typedef struct RTCIRCBUF
     44{
     45    /** The current read position in the buffer. */
     46    size_t          uReadPos;
     47    /** The current write position in the buffer. */
     48    size_t          uWritePos;
     49    /** How much space of the buffer is currently in use. */
     50    volatile size_t cbBufUsed;
     51    /** How big is the buffer. */
     52    size_t          cbBufSize;
     53    /** The buffer itself. */
     54    void           *pvBuf;
     55} RTCIRCBUF;
     56
     57
     58
    3859RTDECL(int) RTCircBufCreate(PRTCIRCBUF *ppBuf, size_t cbSize)
    3960{
  • trunk/src/VBox/Runtime/testcase/tstRTCircBuf.cpp

    r33286 r37210  
    3030#include <iprt/circbuf.h>
    3131
     32#include <iprt/err.h>
    3233#include <iprt/string.h>
    33 #include <iprt/err.h>
    3434#include <iprt/test.h>
    3535
     
    4040static void tst1(void)
    4141{
    42     void *pvBuf = NULL;
    43     size_t cbSize = 0;
     42    void *pvBuf;
     43    size_t cbSize;
    4444
    4545    char pcTestPattern1[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9 };
     
    6262    RTTESTI_CHECK(RTCircBufFree(pBuf) == 0);
    6363    RTTESTI_CHECK(RTCircBufUsed(pBuf) == 10);
    64     RTTESTI_CHECK(memcmp(pBuf->pvBuf, pcTestPattern1, 10) == 0); /* Check the internal state */
     64//    RTTESTI_CHECK(memcmp(pBuf->pvBuf, pcTestPattern1, 10) == 0); /* Check the internal state */
    6565
    6666    /* Half read */
     
    8181    RTTESTI_CHECK(RTCircBufFree(pBuf) == 3);
    8282    RTTESTI_CHECK(RTCircBufUsed(pBuf) == 7);
    83     RTTESTI_CHECK(memcmp(pBuf->pvBuf, pcTestPattern2, 10) == 0); /* Check the internal state */
     83//    RTTESTI_CHECK(memcmp(pBuf->pvBuf, pcTestPattern2, 10) == 0); /* Check the internal state */
    8484
    8585    /* Split tests */
     
    113113    RTTESTI_CHECK(RTCircBufFree(pBuf) == 0);
    114114    RTTESTI_CHECK(RTCircBufUsed(pBuf) == 10);
    115     RTTESTI_CHECK(memcmp(pBuf->pvBuf, pcTestPattern3, 10) == 0); /* Check the internal state */
     115//    RTTESTI_CHECK(memcmp(pBuf->pvBuf, pcTestPattern3, 10) == 0); /* Check the internal state */
    116116
    117117    /* Destroy */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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