tIPStackBuffer *ret;
ret = malloc( sizeof(*ret) + MaxBuffers * sizeof(ret->SubBuffers[0]) );
+ ASSERTR(ret, NULL);
ret->MaxSubBufffers = MaxBuffers;
ret->nSubBuffers = 0;
ret->TotalLength = 0;
void IPStack_Buffer_ClearBuffer(tIPStackBuffer *Buffer)
{
+ ASSERT(Buffer);
IPStack_Buffer_LockBuffer(Buffer);
for( int i = 0; i < Buffer->nSubBuffers; i ++ )
{
void IPStack_Buffer_DestroyBuffer(tIPStackBuffer *Buffer)
{
+ ASSERT(Buffer);
IPStack_Buffer_ClearBuffer(Buffer);
Buffer->MaxSubBufffers = 0;
free(Buffer);
void IPStack_Buffer_LockBuffer(tIPStackBuffer *Buffer)
{
+ ASSERT(Buffer);
Mutex_Acquire(&Buffer->lBufferLock);
}
void IPStack_Buffer_UnlockBuffer(tIPStackBuffer *Buffer)
{
+ ASSERT(Buffer);
Mutex_Release(&Buffer->lBufferLock);
}
tIPStackBufferCb Cb, void *Arg
)
{
+ ASSERT(Buffer);
if( Buffer->nSubBuffers == Buffer->MaxSubBufffers ) {
// Ah, oops?
Log_Error("IPStack", "Buffer %p only had %i sub-buffers allocated, which was not enough",
size_t IPStack_Buffer_GetLength(tIPStackBuffer *Buffer)
{
+ ASSERT(Buffer);
return Buffer->TotalLength;
}
size_t IPStack_Buffer_GetData(tIPStackBuffer *Buffer, void *Dest, size_t MaxBytes)
{
+ ASSERT(Buffer);
Uint8 *dest = Dest;
size_t rem_space = MaxBytes;
size_t len;
void *IPStack_Buffer_CompactBuffer(tIPStackBuffer *Buffer, size_t *Length)
{
- void *ret;
-
- ret = malloc(Buffer->TotalLength);
+ ASSERT(Buffer);
+ void *ret = malloc(Buffer->TotalLength);
if(!ret) {
*Length = 0;
return NULL;
int IPStack_Buffer_GetBuffer(tIPStackBuffer *Buffer, int Index, size_t *Length, const void **DataPtr)
{
+ ASSERT(Buffer);
if( Index == -1 ) Index = 0;
if( Index >= Buffer->nSubBuffers*2 ) {