X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=src%2Fcxr_mem.h;h=437831489ce2c741a810b00401730467abf9b38d;hb=e17cd5d7861480f19148b1eb5b15a520df838b1f;hp=23e61c4e8bec26aa925aa2cd742466a709de0171;hpb=b5ba4ec14b8e215a38cd9072de17fe40f48cea48;p=convexer.git diff --git a/src/cxr_mem.h b/src/cxr_mem.h index 23e61c4..4378314 100644 --- a/src/cxr_mem.h +++ b/src/cxr_mem.h @@ -1,6 +1,6 @@ -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, @@ -16,7 +16,7 @@ struct cxr_auto_buffer #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 @@ -36,7 +36,7 @@ static void *__cxr_ab_ptr( struct cxr_auto_buffer *buffer, u32 index 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 ) { @@ -45,13 +45,13 @@ static void cxr_ab_reserve( struct cxr_auto_buffer *buffer, u32 count ) } } -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 ); @@ -61,7 +61,7 @@ static void *cxr_ab_empty_at( struct cxr_auto_buffer *buffer, int at ) return cxr_ab_ptr( buffer, at ); } - // Shift rest 1 right + /* Shift buffer to make room */ memmove ( cxr_ab_ptr( buffer, at+1 ), @@ -73,7 +73,7 @@ static void *cxr_ab_empty_at( struct cxr_auto_buffer *buffer, int at ) 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 ); @@ -81,7 +81,7 @@ static void cxr_ab_push( struct cxr_auto_buffer *buffer, void *em ) 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); @@ -90,12 +90,12 @@ static void cxr_ab_init( struct cxr_auto_buffer *buffer, u32 esize, u32 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 ); }