DEFINE_EVENT_UNSUBSCRIBE(_name)
#define DEFINE_EVENT_ENTRY(_name) \
- { #_name, { sizeof( _name ## EventArgs), NULL }, 0, { NULL } },
+ { #_name, { sizeof( _name ## EventArgs), NULL }, 0, { NULL } },
struct _wPubSub
{
WINPR_API void BipBuffer_ReadCommit(wBipBuffer* bb, size_t size);
WINPR_API SSIZE_T BipBuffer_Read(wBipBuffer* bb, BYTE* data, size_t size);
- WINPR_API SSIZE_T BipBuffer_Write(wBipBuffer* bb, BYTE* data, size_t size);
+ WINPR_API SSIZE_T BipBuffer_Write(wBipBuffer* bb, const BYTE* data, size_t size);
WINPR_API wBipBuffer* BipBuffer_New(size_t size);
WINPR_API void BipBuffer_Free(wBipBuffer* bb);
return FALSE;
size += size % bb->pageSize;
-
bb->buffer = (BYTE*) malloc(size);
if (!bb->buffer)
return FALSE;
bb->size = size;
-
return TRUE;
}
BYTE* buffer;
size_t blockSize = 0;
size_t commitSize = 0;
-
size += size % bb->pageSize;
if (size <= bb->size)
}
BipBuffer_Clear(bb);
-
free(bb->buffer);
bb->buffer = buffer;
bb->size = size;
-
bb->blockA.index = 0;
bb->blockA.size = commitSize;
-
return TRUE;
}
if (!bb->blockB.size)
{
/* block B does not exist */
-
reservable = bb->size - bb->blockA.index - bb->blockA.size; /* space after block A */
if (reservable >= bb->blockA.index)
bb->writeR.size = reservable;
*reserved = reservable;
-
bb->writeR.index = bb->blockA.index + bb->blockA.size;
return &bb->buffer[bb->writeR.index];
}
bb->writeR.size = size;
*reserved = size;
-
bb->writeR.index = 0;
return bb->buffer;
}
/* block B exists */
-
reservable = bb->blockA.index - bb->blockB.index - bb->blockB.size; /* space after block B */
if (size < reservable)
bb->writeR.size = reservable;
*reserved = reservable;
-
bb->writeR.index = bb->blockB.index + bb->blockB.size;
return &bb->buffer[bb->writeR.index];
}
{
BYTE* block = NULL;
size_t reserved = 0;
-
block = BipBuffer_WriteTryReserve(bb, size, &reserved);
if (reserved == size)
return NULL;
block = BipBuffer_WriteTryReserve(bb, size, &reserved);
-
return block;
}
BipBlock_Clear(bb->writeR);
}
-SSIZE_T BipBuffer_Write(wBipBuffer* bb, BYTE* data, size_t size)
+SSIZE_T BipBuffer_Write(wBipBuffer* bb, const BYTE* data, size_t size)
{
size_t status = 0;
BYTE* block = NULL;
size_t writeSize = 0;
size_t blockSize = 0;
- if (!bb)
+ if (size == 0)
+ return 0;
+
+ if (!bb || !data)
return -1;
+ if (size > SSIZE_MAX)
+ size = SSIZE_MAX;
+
block = BipBuffer_WriteReserve(bb, size);
if (!block)
size_t readSize = 0;
size_t blockSize = 0;
- if (!bb)
+ if (size == 0)
+ return 0;
+
+ if (!bb || !data)
return -1;
+ if (size > SSIZE_MAX)
+ size = SSIZE_MAX;
+
block = BipBuffer_ReadTryReserve(bb, 0, &blockSize);
if (block)
wBipBuffer* BipBuffer_New(size_t size)
{
wBipBuffer* bb;
-
bb = (wBipBuffer*) calloc(1, sizeof(wBipBuffer));
if (bb)
{
SYSTEM_INFO si;
-
GetSystemInfo(&si);
-
bb->pageSize = (size_t) si.dwPageSize;
if (bb->pageSize < 4096)
return;
BipBuffer_FreeBuffer(bb);
-
free(bb);
}