From dbca9cc80d682305440ac4a94c5c72c8cf076021 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Sep 2009 17:08:18 -0700 Subject: http: support Rubies without the OBJ_FROZEN macro Rubinius does not support frozen objects, maybe other Rubies lack support for it as well. --- ext/unicorn_http/ext_help.h | 7 +++++++ ext/unicorn_http/unicorn_http.rl | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/unicorn_http/ext_help.h b/ext/unicorn_http/ext_help.h index 5f7c296..d8bfc7d 100644 --- a/ext/unicorn_http/ext_help.h +++ b/ext/unicorn_http/ext_help.h @@ -18,6 +18,13 @@ static void rb_18_str_set_len(VALUE str, long len) # define rb_str_set_len(str,len) rb_18_str_set_len(str,len) #endif +/* not all Ruby implementations support frozen objects (Rubinius does not) */ +#if defined(OBJ_FROZEN) +# define assert_frozen(f) assert(OBJ_FROZEN(f) && "unfrozen object") +#else +# define assert_frozen(f) assert(!NIL_P(f)) +#endif + static inline int str_cstr_eq(VALUE val, const char *ptr, size_t len) { return (RSTRING_LEN(val) == len && !memcmp(ptr, RSTRING_PTR(val), len)); diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 59748e2..ee23a52 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -192,7 +192,7 @@ static void write_value(VALUE req, struct http_parser *hp, HP_FL_SET(hp, HASTRAILER); hp_invalid_if_trailer(hp); } else { - assert(OBJ_FROZEN(f) && "unfrozen object returned"); + assert_frozen(f); } e = rb_hash_aref(req, f); -- cgit v1.2.3-24-ge0c7