Skip to content

Commit

Permalink
Support mswin
Browse files Browse the repository at this point in the history
  • Loading branch information
unak committed Jun 14, 2017
1 parent 95c382b commit 6aa2bc9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ext/nio4r/bytebuffer.c
Expand Up @@ -124,10 +124,11 @@ static VALUE NIO_ByteBuffer_get_position(VALUE self)

static VALUE NIO_ByteBuffer_set_position(VALUE self, VALUE new_position)
{
int pos;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

int pos = NUM2INT(new_position);
pos = NUM2INT(new_position);

if(pos < 0) {
rb_raise(rb_eArgError, "negative position given");
Expand Down Expand Up @@ -156,10 +157,11 @@ static VALUE NIO_ByteBuffer_get_limit(VALUE self)

static VALUE NIO_ByteBuffer_set_limit(VALUE self, VALUE new_limit)
{
int lim;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

int lim = NUM2INT(new_limit);
lim = NUM2INT(new_limit);

if(lim < 0) {
rb_raise(rb_eArgError, "negative limit given");
Expand Down Expand Up @@ -237,10 +239,11 @@ static VALUE NIO_ByteBuffer_get(int argc, VALUE *argv, VALUE self)

static VALUE NIO_ByteBuffer_fetch(VALUE self, VALUE index)
{
int i;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

int i = NUM2INT(index);
i = NUM2INT(index);

if(i < 0) {
rb_raise(rb_eArgError, "negative index given");
Expand All @@ -255,10 +258,11 @@ static VALUE NIO_ByteBuffer_fetch(VALUE self, VALUE index)

static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
{
long length;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

long length = RSTRING_LEN(string);
length = RSTRING_LEN(string);

if(length > buffer->limit - buffer->position) {
rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
Expand Down

0 comments on commit 6aa2bc9

Please sign in to comment.