-typedef struct cxr_auto_buffer cxr_auto_buffer;
+typedef struct cxr_abuffer cxr_abuffer;
-struct cxr_auto_buffer
+struct cxr_abuffer
{
u8 *arr;
u32 esize,
#define cxr_ab_ptr(b,i) __cxr_ab_ptr(b,i)
#endif
-static void *__cxr_ab_ptr( struct cxr_auto_buffer *buffer, u32 index
+static void *__cxr_ab_ptr( struct cxr_abuffer *buffer, u32 index
#ifdef CXR_DEBUG_ALLOCATORS
,const char *debug_str
return buffer->arr + buffer->esize*index;
}
-static void cxr_ab_reserve( struct cxr_auto_buffer *buffer, u32 count )
+static void cxr_ab_reserve( struct cxr_abuffer *buffer, u32 count )
{
if( buffer->count + count > buffer->capacity )
{
}
}
-static void *cxr_ab_empty( struct cxr_auto_buffer *buffer )
+static void *cxr_ab_empty( struct cxr_abuffer *buffer )
{
cxr_ab_reserve( buffer, 1 );
return cxr_ab_ptr( buffer, buffer->count ++ );
}
-static void *cxr_ab_empty_at( struct cxr_auto_buffer *buffer, int at )
+static void *cxr_ab_empty_at( struct cxr_abuffer *buffer, int at )
{
cxr_ab_reserve( buffer, 1 );
return cxr_ab_ptr( buffer, at );
}
- // Shift rest 1 right
+ /* Shift buffer to make room */
memmove
(
cxr_ab_ptr( buffer, at+1 ),
return cxr_ab_ptr( buffer, at );
}
-static void cxr_ab_push( struct cxr_auto_buffer *buffer, void *em )
+static void cxr_ab_push( struct cxr_abuffer *buffer, void *em )
{
cxr_ab_reserve( buffer, 1 );
buffer->count ++;
}
-static void cxr_ab_init( struct cxr_auto_buffer *buffer, u32 esize, u32 cap )
+static void cxr_ab_init( struct cxr_abuffer *buffer, u32 esize, u32 cap )
{
buffer->esize = esize;
buffer->capacity = cxr_max(1,cap);
buffer->arr = malloc( buffer->esize*buffer->capacity );
}
-static void cxr_ab_clear( struct cxr_auto_buffer *buffer )
+static void cxr_ab_clear( struct cxr_abuffer *buffer )
{
buffer->count = 0;
}
-static void cxr_ab_free( struct cxr_auto_buffer *buffer )
+static void cxr_ab_free( struct cxr_abuffer *buffer )
{
free( buffer->arr );
}