tests: remove typedef around struct gmio_ro_buffer

This commit is contained in:
Hugues Delorme 2016-01-05 11:48:56 +01:00
parent 56241d22f6
commit 02668e0cb0
3 changed files with 15 additions and 14 deletions

View File

@ -19,13 +19,13 @@
static gmio_bool_t gmio_stream_buffer_at_end(void* cookie) static gmio_bool_t gmio_stream_buffer_at_end(void* cookie)
{ {
const gmio_ro_buffer_t* buff = (const gmio_ro_buffer_t*)cookie; const struct gmio_ro_buffer* buff = (const struct gmio_ro_buffer*)cookie;
return buff->pos >= buff->len; return buff->pos >= buff->len;
} }
static int gmio_stream_buffer_error(void* cookie) static int gmio_stream_buffer_error(void* cookie)
{ {
const gmio_ro_buffer_t* buff = (const gmio_ro_buffer_t*)cookie; const struct gmio_ro_buffer* buff = (const struct gmio_ro_buffer*)cookie;
return buff == NULL || buff->pos > buff->len; return buff == NULL || buff->pos > buff->len;
} }
@ -33,7 +33,7 @@ static size_t gmio_stream_buffer_read(
void* cookie, void* ptr, size_t item_size, size_t item_count) void* cookie, void* ptr, size_t item_size, size_t item_count)
{ {
if (item_size > 0 && item_count > 0) { if (item_size > 0 && item_count > 0) {
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie; struct gmio_ro_buffer* buff = (struct gmio_ro_buffer*)cookie;
const void* buff_ptr = buff->ptr; const void* buff_ptr = buff->ptr;
const size_t buff_remaining_size = buff->len - buff->pos; const size_t buff_remaining_size = buff->len - buff->pos;
const size_t wanted_read_size = item_size * item_count; const size_t wanted_read_size = item_size * item_count;
@ -80,25 +80,26 @@ static size_t gmio_stream_buffer_write(
static gmio_streamsize_t gmio_stream_buffer_size(void* cookie) static gmio_streamsize_t gmio_stream_buffer_size(void* cookie)
{ {
const gmio_ro_buffer_t* buff = (const gmio_ro_buffer_t*)cookie; const struct gmio_ro_buffer* buff = (const struct gmio_ro_buffer*)cookie;
return buff->len; return buff->len;
} }
static int gmio_stream_buffer_get_pos(void* cookie, struct gmio_streampos* pos) static int gmio_stream_buffer_get_pos(void* cookie, struct gmio_streampos* pos)
{ {
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie; struct gmio_ro_buffer* buff = (struct gmio_ro_buffer*)cookie;
memcpy(&pos->cookie[0], &buff->pos, sizeof(size_t)); memcpy(&pos->cookie[0], &buff->pos, sizeof(size_t));
return 0; return 0;
} }
static int gmio_stream_buffer_set_pos(void* cookie, const struct gmio_streampos* pos) static int gmio_stream_buffer_set_pos(
void* cookie, const struct gmio_streampos* pos)
{ {
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie; struct gmio_ro_buffer* buff = (struct gmio_ro_buffer*)cookie;
memcpy(&buff->pos, &pos->cookie[0], sizeof(size_t)); memcpy(&buff->pos, &pos->cookie[0], sizeof(size_t));
return 0; return 0;
} }
struct gmio_stream gmio_istream_buffer(gmio_ro_buffer_t* buff) struct gmio_stream gmio_istream_buffer(struct gmio_ro_buffer* buff)
{ {
struct gmio_stream stream = {0}; struct gmio_stream stream = {0};
stream.cookie = buff; stream.cookie = buff;
@ -113,7 +114,8 @@ struct gmio_stream gmio_istream_buffer(gmio_ro_buffer_t* buff)
struct gmio_stream gmio_stream_buffer(struct gmio_rw_buffer* buff) struct gmio_stream gmio_stream_buffer(struct gmio_rw_buffer* buff)
{ {
struct gmio_stream stream = gmio_istream_buffer((gmio_ro_buffer_t*)buff); struct gmio_stream stream =
gmio_istream_buffer((struct gmio_ro_buffer*)buff);
stream.func_write = gmio_stream_buffer_write; stream.func_write = gmio_stream_buffer_write;
return stream; return stream;
} }

View File

@ -25,7 +25,6 @@ struct gmio_ro_buffer
size_t len; size_t len;
size_t pos; size_t pos;
}; };
typedef struct gmio_ro_buffer gmio_ro_buffer_t;
/* Read/write buffer */ /* Read/write buffer */
struct gmio_rw_buffer struct gmio_rw_buffer
@ -35,7 +34,7 @@ struct gmio_rw_buffer
size_t pos; size_t pos;
}; };
struct gmio_stream gmio_istream_buffer(gmio_ro_buffer_t* buff); struct gmio_stream gmio_istream_buffer(struct gmio_ro_buffer* buff);
struct gmio_stream gmio_iostream_buffer(struct gmio_rw_buffer* buff); struct gmio_stream gmio_iostream_buffer(struct gmio_rw_buffer* buff);
#endif /* GMIO_STREAM_BUFFER_H */ #endif /* GMIO_STREAM_BUFFER_H */

View File

@ -132,7 +132,7 @@ const char* test_internal__gmio_fast_atof()
{ {
char strbuff[2048] = {0}; char strbuff[2048] = {0};
struct gmio_stringstream sstream = {0}; struct gmio_stringstream sstream = {0};
gmio_ro_buffer_t streambuff = { fstr, sizeof(fstr) - 1, 0 }; struct gmio_ro_buffer streambuff = { fstr, sizeof(fstr) - 1, 0 };
float f2; float f2;
sstream.stream = gmio_istream_buffer(&streambuff); sstream.stream = gmio_istream_buffer(&streambuff);
@ -178,7 +178,7 @@ const char* test_internal__stringstream()
"Parfois le chemin est rude.\n" "Parfois le chemin est rude.\n"
"pi : 3.1415926535897932384626433832795"; "pi : 3.1415926535897932384626433832795";
{ {
gmio_ro_buffer_t buff = { text, sizeof(text) - 1, 0 }; struct gmio_ro_buffer buff = { text, sizeof(text) - 1, 0 };
char small_fwd_it_str[4]; char small_fwd_it_str[4];
char fwd_it_str[32]; char fwd_it_str[32];
@ -234,7 +234,7 @@ const char* test_internal__stringstream()
} }
{ {
gmio_ro_buffer_t buff = { text, sizeof(text) - 1, 0 }; struct gmio_ro_buffer buff = { text, sizeof(text) - 1, 0 };
char fwd_it_str[32]; char fwd_it_str[32];
struct gmio_stringstream fwd_it = {0}; struct gmio_stringstream fwd_it = {0};