Refactor: Use size_t for {w,r}streams.c

This commit is contained in:
Thiago de Arruda
2014-05-27 09:12:49 -03:00
parent 1faf546ea2
commit 1c308e28f1
4 changed files with 12 additions and 12 deletions

View File

@@ -33,7 +33,7 @@ static void close_cb(uv_handle_t *handle);
static void emit_read_event(RStream *rstream, bool eof);
RStream * rstream_new(rstream_cb cb,
uint32_t buffer_size,
size_t buffer_size,
void *data,
bool async)
{
@@ -133,7 +133,7 @@ void rstream_stop(RStream *rstream)
}
}
size_t rstream_read(RStream *rstream, char *buf, uint32_t count)
size_t rstream_read(RStream *rstream, char *buf, size_t count)
{
size_t read_count = rstream->wpos - rstream->rpos;

View File

@@ -21,7 +21,7 @@
/// this to false
/// @return The newly-allocated `RStream` instance
RStream * rstream_new(rstream_cb cb,
uint32_t buffer_size,
size_t buffer_size,
void *data,
bool async);
@@ -65,7 +65,7 @@ void rstream_stop(RStream *rstream);
/// @param buffer The buffer which will receive the data
/// @param count Number of bytes that `buffer` can accept
/// @return The number of bytes copied into `buffer`
size_t rstream_read(RStream *rstream, char *buffer, uint32_t count);
size_t rstream_read(RStream *rstream, char *buffer, size_t count);
/// Returns the number of bytes available for reading from `rstream`
///

View File

@@ -12,11 +12,11 @@
struct wstream {
uv_stream_t *stream;
// Memory currently used by pending buffers
uint32_t curmem;
size_t curmem;
// Maximum memory used by this instance
uint32_t maxmem;
size_t maxmem;
// Number of pending requests
uint32_t pending_reqs;
size_t pending_reqs;
bool freed;
};
@@ -25,14 +25,14 @@ typedef struct {
// Buffer containing data to be written
char *buffer;
// Size of the buffer
uint32_t length;
size_t length;
// If it's our responsibility to free the buffer
bool free;
} WriteData;
static void write_cb(uv_write_t *req, int status);
WStream * wstream_new(uint32_t maxmem)
WStream * wstream_new(size_t maxmem)
{
WStream *rv = xmalloc(sizeof(WStream));
rv->maxmem = maxmem;
@@ -59,7 +59,7 @@ void wstream_set_stream(WStream *wstream, uv_stream_t *stream)
wstream->stream = stream;
}
bool wstream_write(WStream *wstream, char *buffer, uint32_t length, bool free)
bool wstream_write(WStream *wstream, char *buffer, size_t length, bool free)
{
WriteData *data;
uv_buf_t uvbuf;

View File

@@ -12,7 +12,7 @@
///
/// @param maxmem Maximum amount memory used by this `WStream` instance.
/// @return The newly-allocated `WStream` instance
WStream * wstream_new(uint32_t maxmem);
WStream * wstream_new(size_t maxmem);
/// Frees all memory allocated for a WStream instance
///
@@ -34,7 +34,7 @@ void wstream_set_stream(WStream *wstream, uv_stream_t *stream);
/// @param length Number of bytes that should be written from `buffer`
/// @param free If true, `buffer` will be freed after the write is complete
/// @return true if the data was successfully queued, false otherwise.
bool wstream_write(WStream *wstream, char *buffer, uint32_t length, bool free);
bool wstream_write(WStream *wstream, char *buffer, size_t length, bool free);
#endif // NVIM_OS_WSTREAM_H