[前][次][番号順一覧][スレッド一覧]

ruby-changes:36957

From: nobu <ko1@a...>
Date: Sat, 27 Dec 2014 20:13:41 +0900 (JST)
Subject: [ruby-changes:36957] nobu:r49038 (trunk): json: backward compatibilities

nobu	2014-12-27 20:12:58 +0900 (Sat, 27 Dec 2014)

  New Revision: 49038

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49038

  Log:
    json: backward compatibilities
    
    * ext/json/generator/generator.c (JSON_Generator_State_type): add
      #ifdef for backward compatibility.
    * ext/json/parser/parser.rl (JSON_Parser_type): ditto.
    * ext/json/generator/generator.h (ZALLOC): add fallback definition.
    * ext/json/parser/parser.h (ZALLOC): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/ext/json/generator/generator.c
    trunk/ext/json/generator/generator.h
    trunk/ext/json/parser/parser.c
    trunk/ext/json/parser/parser.h
    trunk/ext/json/parser/parser.rl
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49037)
+++ ChangeLog	(revision 49038)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 27 20:12:55 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/json/generator/generator.c (JSON_Generator_State_type): add
+	  #ifdef for backward compatibility.
+
+	* ext/json/parser/parser.rl (JSON_Parser_type): ditto.
+
+	* ext/json/generator/generator.h (ZALLOC): add fallback definition.
+
+	* ext/json/parser/parser.h (ZALLOC): ditto.
+
 Sat Dec 27 16:54:05 2014  Tanaka Akira  <akr@f...>
 
 	* process.c: Unused code removed.
Index: ext/json/generator/generator.c
===================================================================
--- ext/json/generator/generator.c	(revision 49037)
+++ ext/json/generator/generator.c	(revision 49038)
@@ -518,8 +518,10 @@ static size_t State_memsize(const void * https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L518
 static const rb_data_type_t JSON_Generator_State_type = {
     "JSON/Generator/State",
     {NULL, State_free, State_memsize,},
+#ifdef RUBY_TYPED_FREE_IMMEDIATELY
     0, 0,
     RUBY_TYPED_FREE_IMMEDIATELY,
+#endif
 };
 
 static JSON_Generator_State *State_allocate(void)
Index: ext/json/generator/generator.h
===================================================================
--- ext/json/generator/generator.h	(revision 49037)
+++ ext/json/generator/generator.h	(revision 49038)
@@ -149,4 +149,14 @@ static VALUE cState_depth_set(VALUE self https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.h#L149
 static FBuffer *cState_prepare_buffer(VALUE self);
 static const rb_data_type_t JSON_Generator_State_type;
 
+#ifndef ZALLOC
+#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
+static inline void *ruby_zalloc(size_t n)
+{
+    void *p = ruby_xmalloc(n);
+    memset(p, 0, n);
+    return p;
+}
+#endif
+
 #endif
Index: ext/json/parser/parser.h
===================================================================
--- ext/json/parser/parser.h	(revision 49037)
+++ ext/json/parser/parser.h	(revision 49038)
@@ -75,4 +75,14 @@ static VALUE cJSON_parser_s_allocate(VAL https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.h#L75
 static VALUE cParser_source(VALUE self);
 static const rb_data_type_t JSON_Parser_type;
 
+#ifndef ZALLOC
+#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
+static inline void *ruby_zalloc(size_t n)
+{
+    void *p = ruby_xmalloc(n);
+    memset(p, 0, n);
+    return p;
+}
+#endif
+
 #endif
Index: ext/json/parser/parser.rl
===================================================================
--- ext/json/parser/parser.rl	(revision 49037)
+++ ext/json/parser/parser.rl	(revision 49038)
@@ -817,8 +817,7 @@ static VALUE cParser_parse(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L817
 
 static JSON_Parser *JSON_allocate(void)
 {
-    JSON_Parser *json = ALLOC(JSON_Parser);
-    MEMZERO(json, JSON_Parser, 1);
+    JSON_Parser *json = ZALLOC(JSON_Parser);
     json->fbuffer = fbuffer_alloc(0);
     return json;
 }
@@ -849,8 +848,10 @@ static size_t JSON_memsize(const void *p https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L848
 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)
Index: ext/json/parser/parser.c
===================================================================
--- ext/json/parser/parser.c	(revision 49037)
+++ ext/json/parser/parser.c	(revision 49038)
@@ -2094,8 +2094,7 @@ static VALUE cParser_parse(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L2094
 
 static JSON_Parser *JSON_allocate(void)
 {
-    JSON_Parser *json = ALLOC(JSON_Parser);
-    MEMZERO(json, JSON_Parser, 1);
+    JSON_Parser *json = ZALLOC(JSON_Parser);
     json->fbuffer = fbuffer_alloc(0);
     return json;
 }
@@ -2126,8 +2125,10 @@ static size_t JSON_memsize(const void *p https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L2125
 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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]