use ruby allocation macros
This commit is contained in:
parent
5e1f827b09
commit
0ac6f2b4ed
@ -39,12 +39,12 @@ static void write_doc(bson_buffer* buffer, VALUE hash);
|
|||||||
|
|
||||||
static bson_buffer* buffer_new(void) {
|
static bson_buffer* buffer_new(void) {
|
||||||
bson_buffer* buffer;
|
bson_buffer* buffer;
|
||||||
buffer = (bson_buffer*)malloc(sizeof(bson_buffer));
|
buffer = ALLOC(bson_buffer);
|
||||||
assert(buffer);
|
assert(buffer);
|
||||||
|
|
||||||
buffer->size = INITIAL_BUFFER_SIZE;
|
buffer->size = INITIAL_BUFFER_SIZE;
|
||||||
buffer->position = 0;
|
buffer->position = 0;
|
||||||
buffer->buffer = (char*)malloc(INITIAL_BUFFER_SIZE);
|
buffer->buffer = ALLOC_N(char, INITIAL_BUFFER_SIZE);
|
||||||
assert(buffer->buffer);
|
assert(buffer->buffer);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -66,7 +66,7 @@ static void buffer_resize(bson_buffer* buffer, int min_length) {
|
|||||||
while (size < min_length) {
|
while (size < min_length) {
|
||||||
size *= 2;
|
size *= 2;
|
||||||
}
|
}
|
||||||
buffer->buffer = (char*)realloc(buffer->buffer, size);
|
buffer->buffer = REALLOC_N(buffer->buffer, char, size);
|
||||||
assert(buffer->buffer);
|
assert(buffer->buffer);
|
||||||
buffer->size = size;
|
buffer->size = size;
|
||||||
}
|
}
|
||||||
@ -182,6 +182,7 @@ static int write_element(VALUE key, VALUE value, VALUE extra) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// case T_DATA:
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eTypeError, "no c encoder for this type yet");
|
rb_raise(rb_eTypeError, "no c encoder for this type yet");
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user