diff options
author | Florian Frank <flori@ping.de> | 2015-01-02 21:31:20 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2015-01-02 21:31:20 +0100 |
commit | cb3656bb25eb37eb02a4d955a6e4c094aecf74f4 (patch) | |
tree | c7426fc85de55662eb02f6cc00c486195242fb30 /ext/json/ext/parser/parser.c | |
parent | 6ae8732ef0e7a59e3457495f150c582301c00c7c (diff) | |
parent | b798187c278beea246b0f709754ebd34eaae074e (diff) | |
download | json-cb3656bb25eb37eb02a4d955a6e4c094aecf74f4.tar.gz |
Merge branch 'ruby-2.2' of https://github.com/zzak/json into zzak-ruby-2.2
Conflicts:
.travis.yml
json.gemspec
json_pure.gemspec
Diffstat (limited to 'ext/json/ext/parser/parser.c')
-rw-r--r-- | ext/json/ext/parser/parser.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index e91e161..efb4dac 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -2092,7 +2092,7 @@ static VALUE cParser_parse(VALUE self) } -static JSON_Parser *JSON_allocate() +static JSON_Parser *JSON_allocate(void) { JSON_Parser *json = ALLOC(JSON_Parser); MEMZERO(json, JSON_Parser, 1); @@ -2100,8 +2100,9 @@ static JSON_Parser *JSON_allocate() return json; } -static void JSON_mark(JSON_Parser *json) +static void JSON_mark(void *ptr) { + JSON_Parser *json = ptr; rb_gc_mark_maybe(json->Vsource); rb_gc_mark_maybe(json->create_id); rb_gc_mark_maybe(json->object_class); @@ -2109,16 +2110,32 @@ static void JSON_mark(JSON_Parser *json) rb_gc_mark_maybe(json->match_string); } -static void JSON_free(JSON_Parser *json) +static void JSON_free(void *ptr) { + JSON_Parser *json = ptr; fbuffer_free(json->fbuffer); ruby_xfree(json); } +static size_t JSON_memsize(const void *ptr) +{ + const JSON_Parser *json = ptr; + return sizeof(*json) + FBUFFER_CAPA(json->fbuffer); +} + +static const rb_data_type_t JSON_Parser_type = { + "JSON/Parser", + {JSON_mark, JSON_free, JSON_memsize,}, +#ifdef RUBY_TYPED_FREE_IMMEDIATELY + 0, 0, + RUBY_TYPED_FREE_IMMEDIATELY, +#endif +}; + static VALUE cJSON_parser_s_allocate(VALUE klass) { JSON_Parser *json = JSON_allocate(); - return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json); + return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json); } /* |