bool modified;
do
{
- const int len = strlen(str);
+ const size_t len = strlen(str);
modified = false;
if (len > 0)
{
{
if (str)
{
- const int n = strlen(str) + 1;
+ const size_t n = strlen(str) + 1;
char *ret;
if (gc)
bool
buf_string_match_head_str(const struct buffer *src, const char *match)
{
- const int size = strlen(match);
+ const size_t size = strlen(match);
if (size < 0 || size > src->len)
{
return false;
{
if (buf_string_match_head_str(src, match))
{
- buf_advance(src, strlen(match));
+ buf_advance(src, (int)strlen(match));
return true;
}
else
struct buffer_entry *e = buffer_list_push_data(ol, str, len+1);
if (e)
{
- e->buf.len = len; /* Don't count trailing '\0' as part of length */
+ e->buf.len = (int)len; /* Don't count trailing '\0' as part of length */
}
}
}
buffer_list_aggregate_separator(struct buffer_list *bl, const size_t max_len,
const char *sep)
{
- const int sep_len = strlen(sep);
+ const size_t sep_len = strlen(sep);
struct buffer_entry *more = bl->head;
size_t size = 0;
int count = 0;
{
struct buffer ret = { 0 };
- platform_stat_t file_stat = {0};
+ platform_stat_t file_stat = { 0 };
if (platform_stat(filename, &file_stat) < 0)
{
return ret;
const size_t size = file_stat.st_size;
ret = alloc_buf_gc(size + 1, gc); /* space for trailing \0 */
- ssize_t read_size = fread(BPTR(&ret), 1, size, fp);
- if (read_size < 0)
+ size_t read_size = fread(BPTR(&ret), 1, size, fp);
+ if (read_size == 0)
{
free_buf_gc(&ret, gc);
goto cleanup;
}
- ASSERT(buf_inc_len(&ret, read_size));
+ ASSERT(buf_inc_len(&ret, (int)read_size));
buf_null_terminate(&ret);
cleanup:
}
static inline void
-buf_set_read(struct buffer *buf, const uint8_t *data, int size)
+buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
{
if (!buf_size_valid(size))
{
buf_size_error(size);
}
- buf->len = buf->capacity = size;
+ buf->len = buf->capacity = (int)size;
buf->offset = 0;
buf->data = (uint8_t *)data;
}
*/
static inline bool
-buf_safe(const struct buffer *buf, int len)
+buf_safe(const struct buffer *buf, size_t len)
{
return buf_valid(buf) && buf_size_valid(len)
- && buf->offset + buf->len + len <= buf->capacity;
+ && buf->offset + buf->len + (int)len <= buf->capacity;
}
static inline bool
{
if (buf_valid(buf) && buf_size_valid_signed(len))
{
- const int newlen = buf->len + len;
+ int newlen = buf->len + len;
return newlen >= 0 && buf->offset + newlen <= buf->capacity;
}
else
*/
static inline uint8_t *
-buf_write_alloc(struct buffer *buf, int size)
+buf_write_alloc(struct buffer *buf, size_t size)
{
uint8_t *ret;
if (!buf_safe(buf, size))
return NULL;
}
ret = BPTR(buf) + buf->len;
- buf->len += size;
+ buf->len += (int)size;
return ret;
}
}
static inline bool
-buf_write(struct buffer *dest, const void *src, int size)
+buf_write(struct buffer *dest, const void *src, size_t size)
{
uint8_t *cp = buf_write_alloc(dest, size);
if (!cp)