Skip to content

Commit 0d7448e

Browse files
committed
Change buffer-related sizes & indices to size_t or ssize_t, as applicable.
1 parent 8a09627 commit 0d7448e

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

src/format_ebml.c

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ typedef struct ebml_client_data_st ebml_client_data_t;
130130
struct ebml_client_data_st {
131131

132132
refbuf_t *header;
133-
int header_pos;
133+
size_t header_pos;
134134

135135
};
136136

@@ -140,19 +140,19 @@ struct ebml_st {
140140
ebml_parsing_state parse_state;
141141
unsigned long long copy_len;
142142

143-
int cluster_start;
143+
ssize_t cluster_start;
144144
ebml_keyframe_status cluster_starts_with_keyframe;
145145
int flush_cluster;
146146

147-
int position;
147+
size_t position;
148148
unsigned char *buffer;
149149

150-
int input_position;
150+
size_t input_position;
151151
unsigned char *input_buffer;
152152

153-
int header_size;
154-
int header_position;
155-
int header_read_position;
153+
size_t header_size;
154+
size_t header_position;
155+
size_t header_read_position;
156156
unsigned char *header;
157157

158158
unsigned long long keyframe_track_number;
@@ -169,21 +169,21 @@ static void ebml_free_client_data(client_t *client);
169169

170170
static ebml_t *ebml_create();
171171
static void ebml_destroy(ebml_t *ebml);
172-
static int ebml_read_space(ebml_t *ebml);
173-
static int ebml_read(ebml_t *ebml, char *buffer, int len, ebml_chunk_type *chunk_type);
174-
static unsigned char *ebml_get_write_buffer(ebml_t *ebml, int *bytes);
175-
static int ebml_wrote(ebml_t *ebml, int len);
176-
static int ebml_parse_tag(unsigned char *buffer,
177-
unsigned char *buffer_end,
178-
unsigned long long *payload_length);
179-
static int ebml_parse_var_int(unsigned char *buffer,
172+
static size_t ebml_read_space(ebml_t *ebml);
173+
static size_t ebml_read(ebml_t *ebml, char *buffer, size_t len, ebml_chunk_type *chunk_type);
174+
static unsigned char *ebml_get_write_buffer(ebml_t *ebml, size_t *bytes);
175+
static ssize_t ebml_wrote(ebml_t *ebml, size_t len);
176+
static ssize_t ebml_parse_tag(unsigned char *buffer,
180177
unsigned char *buffer_end,
181-
unsigned long long *out_value);
182-
static int ebml_parse_sized_int(unsigned char *buffer,
183-
unsigned char *buffer_end,
184-
int len,
185-
int is_signed,
186-
unsigned long long *out_value);
178+
unsigned long long *payload_length);
179+
static ssize_t ebml_parse_var_int(unsigned char *buffer,
180+
unsigned char *buffer_end,
181+
unsigned long long *out_value);
182+
static ssize_t ebml_parse_sized_int(unsigned char *buffer,
183+
unsigned char *buffer_end,
184+
size_t len,
185+
int is_signed,
186+
unsigned long long *out_value);
187187
static inline void ebml_check_track(ebml_t *ebml);
188188

189189
int format_ebml_get_plugin(source_t *source)
@@ -229,7 +229,7 @@ static int send_ebml_header(client_t *client)
229229
{
230230

231231
ebml_client_data_t *ebml_client_data = client->format_data;
232-
int len = EBML_SLICE_SIZE;
232+
size_t len = EBML_SLICE_SIZE;
233233
int ret;
234234

235235
if (ebml_client_data->header->len - ebml_client_data->header_pos < len)
@@ -278,11 +278,11 @@ static refbuf_t *ebml_get_buffer(source_t *source)
278278
ebml_source_state_t *ebml_source_state = source->format->_state;
279279
format_plugin_t *format = source->format;
280280
unsigned char *write_buffer = NULL;
281-
int read_bytes = 0;
282-
int write_bytes = 0;
281+
size_t read_bytes = 0;
282+
size_t write_bytes = 0;
283283
ebml_chunk_type chunk_type;
284284
refbuf_t *refbuf;
285-
int ret;
285+
size_t ret;
286286

287287
while (1)
288288
{
@@ -429,10 +429,10 @@ static ebml_t *ebml_create()
429429
/* Return the size of a buffer needed to store the next
430430
* chunk that ebml_read can yield.
431431
*/
432-
static int ebml_read_space(ebml_t *ebml)
432+
static size_t ebml_read_space(ebml_t *ebml)
433433
{
434434

435-
int read_space;
435+
size_t read_space;
436436

437437
switch (ebml->output_state) {
438438
case EBML_STATE_READING_HEADER:
@@ -486,11 +486,11 @@ static int ebml_read_space(ebml_t *ebml)
486486
* chunk_type will be set to indicate if the chunk is the header,
487487
* the start of a cluster, or continuing the current cluster.
488488
*/
489-
static int ebml_read(ebml_t *ebml, char *buffer, int len, ebml_chunk_type *chunk_type)
489+
static size_t ebml_read(ebml_t *ebml, char *buffer, size_t len, ebml_chunk_type *chunk_type)
490490
{
491491

492-
int read_space;
493-
int to_read;
492+
size_t read_space;
493+
size_t to_read;
494494

495495
*chunk_type = EBML_CHUNK_HEADER;
496496

@@ -584,24 +584,24 @@ static int ebml_read(ebml_t *ebml, char *buffer, int len, ebml_chunk_type *chunk
584584
* Returns the start of the writable space;
585585
* Sets bytes to the amount of space available.
586586
*/
587-
static unsigned char *ebml_get_write_buffer(ebml_t *ebml, int *bytes)
587+
static unsigned char *ebml_get_write_buffer(ebml_t *ebml, size_t *bytes)
588588
{
589589
*bytes = EBML_SLICE_SIZE - ebml->input_position;
590590
return ebml->input_buffer + ebml->input_position;
591591
}
592592

593593
/* Process data that has been written to the EBML parser's input buffer.
594594
*/
595-
static int ebml_wrote(ebml_t *ebml, int len)
595+
static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
596596
{
597597
int processing = 1;
598-
int cursor = 0;
599-
int to_copy;
598+
size_t cursor = 0;
599+
size_t to_copy;
600600
unsigned char *end_of_buffer;
601601

602-
int tag_length;
603-
int value_length;
604-
int track_number_length;
602+
ssize_t tag_length;
603+
ssize_t value_length;
604+
ssize_t track_number_length;
605605
unsigned long long payload_length;
606606
unsigned long long data_value;
607607
unsigned long long track_number;
@@ -861,12 +861,12 @@ static inline void ebml_check_track(ebml_t *ebml)
861861
* Returns -1 if the tag is corrupt.
862862
*/
863863

864-
static int ebml_parse_tag(unsigned char *buffer,
865-
unsigned char *buffer_end,
866-
unsigned long long *payload_length)
864+
static ssize_t ebml_parse_tag(unsigned char *buffer,
865+
unsigned char *buffer_end,
866+
unsigned long long *payload_length)
867867
{
868-
int type_length;
869-
int size_length;
868+
size_t type_length;
869+
size_t size_length;
870870
unsigned long long value;
871871

872872
*payload_length = 0;
@@ -894,12 +894,12 @@ static int ebml_parse_tag(unsigned char *buffer,
894894
* Else, returns the length of the number in bytes and writes the
895895
* value to *out_value.
896896
*/
897-
static int ebml_parse_var_int(unsigned char *buffer,
898-
unsigned char *buffer_end,
899-
unsigned long long *out_value)
897+
static ssize_t ebml_parse_var_int(unsigned char *buffer,
898+
unsigned char *buffer_end,
899+
unsigned long long *out_value)
900900
{
901-
int size = 1;
902-
int i;
901+
size_t size = 1;
902+
size_t i;
903903
unsigned char mask = 0x80;
904904
unsigned long long value;
905905
unsigned long long unknown_marker;
@@ -959,14 +959,14 @@ static int ebml_parse_var_int(unsigned char *buffer,
959959
* Else, returns the length of the number in bytes and writes the
960960
* value to *out_value.
961961
*/
962-
static int ebml_parse_sized_int(unsigned char *buffer,
963-
unsigned char *buffer_end,
964-
int len,
965-
int is_signed,
966-
unsigned long long *out_value)
962+
static ssize_t ebml_parse_sized_int(unsigned char *buffer,
963+
unsigned char *buffer_end,
964+
size_t len,
965+
int is_signed,
966+
unsigned long long *out_value)
967967
{
968968
long long value;
969-
int i;
969+
size_t i;
970970

971971
if (len < 1 || len > 8) {
972972
ICECAST_LOG_DEBUG("Sized int of %i bytes", len);

0 commit comments

Comments
 (0)