Skip to content

Commit

Permalink
moved buffer initialization to allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Cardoso committed Aug 24, 2017
1 parent 9ecf920 commit 9933c42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/nio4r/bytebuffer.c
Expand Up @@ -75,6 +75,7 @@ void Init_NIO_ByteBuffer()
static VALUE NIO_ByteBuffer_allocate(VALUE klass)
{
struct NIO_ByteBuffer *bytebuffer = (struct NIO_ByteBuffer *)xmalloc(sizeof(struct NIO_ByteBuffer));
bytebuffer->buffer = NULL;
return Data_Wrap_Struct(klass, NIO_ByteBuffer_gc_mark, NIO_ByteBuffer_free, bytebuffer);
}

Expand All @@ -94,7 +95,6 @@ static VALUE NIO_ByteBuffer_initialize(VALUE self, VALUE capacity)
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

buffer->buffer = NULL;
buffer->capacity = NUM2INT(capacity);
buffer->buffer = xmalloc(buffer->capacity);

Expand Down

0 comments on commit 9933c42

Please sign in to comment.